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

Annotation of /trunk/pg/macros/parserNumberWithUnits.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6058 - (view) (download) (as text)

1 : sh002i 5556 ################################################################################
2 :     # WeBWorK Online Homework Delivery System
3 :     # Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4 : gage 6058 # $CVSHeader$
5 : sh002i 5556 #
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 : sh002i 5553 =head1 NAME
18 : dpvc 2731
19 : sh002i 5553 parserNumberWithUnits.pl - Implements a number with units.
20 :    
21 : gage 4997 =head1 DESCRIPTION
22 :    
23 : sh002i 5553 This is a Parser class that implements a number with units.
24 :     It is a temporary version until the Parser can handle it
25 :     directly.
26 : dpvc 2731
27 : sh002i 5553 Use NumberWithUnits("num units") or NumberWithUnits(formula,"units")
28 :     to generate a NumberWithUnits object, and then call its cmp method
29 :     to get an answer checker for your number with units.
30 : gage 4997
31 : sh002i 5553 Usage examples:
32 :    
33 : sh002i 5555 ANS(NumberWithUnits("3 ft")->cmp);
34 :     ANS(NumberWithUnits("$a*$b ft")->cmp);
35 :     ANS(NumberWithUnits($a*$b,"ft")->cmp);
36 : sh002i 5553
37 :     We now call on the Legacy version, which is used by
38 :     num_cmp to handle numbers with units.
39 :    
40 : gage 4997 =cut
41 :    
42 : sh002i 5553 loadMacros('MathObjects.pl');
43 :    
44 : dpvc 5392 sub _parserNumberWithUnits_init {
45 :     main::PG_restricted_eval('sub NumberWithUnits {Parser::Legacy::NumberWithUnits->new(@_)}');
46 :     }
47 : dpvc 2731
48 :     1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9