[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 4673 - (download) (as text) (annotate)
Mon Nov 27 04:21:59 2006 UTC (13 years, 2 months ago) by dpvc
File size: 943 byte(s)
Moved the guts of this to pg/lib/Parser/Legacy/NumberWithUnits.pl,
since most of the code is common.  This is a shell that now only
defines the FormulaWithUnits() function.

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9