[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 5556 - (download) (as text) (annotate)
Thu Oct 4 16:40:49 2007 UTC (12 years, 4 months ago) by sh002i
File size: 1804 byte(s)
added standard copyright/license header

    1 ################################################################################
    2 # WeBWorK Online Homework Delivery System
    3 # Copyright  2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
    4 # $CVSHeader: webwork2/lib/WeBWorK.pm,v 1.100 2007/08/13 22:59:53 sh002i Exp $
    5 #
    6 # This program is free software; you can redistribute it and/or modify it under
    7 # the terms of either: (a) the GNU General Public License as published by the
    8 # Free Software Foundation; either version 2, or (at your option) any later
    9 # version, or (b) the "Artistic License" which comes with this package.
   10 #
   11 # This program is distributed in the hope that it will be useful, but WITHOUT
   12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   13 # FOR A PARTICULAR PURPOSE.  See either the GNU General Public License or the
   14 # Artistic License for more details.
   15 ################################################################################
   16 
   17 =head1 NAME
   18 
   19 parserFormulaWithUnits.pl - Implements a formula with units.
   20 
   21 =head1 DESCRIPTION
   22 
   23 This is a Parser class that implements a formula with units.
   24 It is a temporary version until the Parser can handle it
   25 directly.
   26 
   27 Use FormulaWithUnits("num units") or FormulaWithUnits(formula,"units")
   28 to generate a FormulaWithUnits object, and then call its cmp() method
   29 to get an answer checker for your formula with units.
   30 
   31 =head1 USAGE
   32 
   33   ANS(FormulaWithUnits("3x+1 ft")->cmp);
   34   ANS(FormulaWithUnits("$a*x+1 ft")->cmp);
   35 
   36   $x = Formula("x");
   37   ANS(FormulaWithUnits($a*$x+1,"ft")->cmp);
   38 
   39 =cut
   40 
   41 loadMacros('MathObjects.pl');
   42 
   43  #
   44  #  Now uses the version in Parser::Legacy::NumberWithUnits
   45  #  to avoid duplication of common code.
   46  #
   47 
   48 sub _parserFormulaWithUnits_init {
   49   main::PG_restricted_eval('sub FormulaWithUnits {Parser::Legacy::FormulaWithUnits->new(@_)}');
   50 }
   51 
   52 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9