[system] / trunk / pg / macros / parserFormulaWithUnits.pl Repository:
ViewVC logotype

View of /trunk/pg/macros/parserFormulaWithUnits.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5392 - (download) (as text) (annotate)
Sun Aug 19 21:50:23 2007 UTC (12 years, 6 months ago) by dpvc
File size: 1007 byte(s)
Move the context creation to the _init routine so that modifications
to main:: occur at initialization time, not when the file is loaded.

    1 
    2 loadMacros('MathObjects.pl');
    3 
    4 =head1 DESCRIPTION
    5 
    6  ######################################################################
    7  #
    8  #  This is a Parser class that implements a formula with units.
    9  #  It is a temporary version until the Parser can handle it
   10  #  directly.
   11  #
   12  #  Use FormulaWithUnits("num units") or FormulaWithUnits(formula,"units")
   13  #  to generate a FormulaWithUnits object, and then call its cmp() method
   14  #  to get an answer checker for your formula with units.
   15  #
   16  #  Usage examples:
   17  #
   18  #      ANS(FormulaWithUnits("3x+1 ft")->cmp);
   19  #      ANS(FormulaWithUnits("$a*x+1 ft")->cmp);
   20  #
   21  #      $x = Formula("x");
   22  #      ANS(FormulaWithUnits($a*$x+1,"ft")->cmp);
   23  #
   24  ######################################################################
   25 
   26  #
   27  #  Now uses the version in Parser::Legacy::NumberWithUnits
   28  #  to avoid duplication of common code.
   29  #
   30 
   31 =cut
   32 
   33 sub _parserFormulaWithUnits_init {
   34   main::PG_restricted_eval('sub FormulaWithUnits {Parser::Legacy::FormulaWithUnits->new(@_)}');
   35 }
   36 
   37 1;
   38 

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9