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

Diff of /trunk/pg/macros/parserFunction.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5372 Revision 5373
3 3
4sub _parserFunction_init {}; # don't reload this file 4sub _parserFunction_init {}; # don't reload this file
5 5
6=head1 DESCRIPTION 6=head1 DESCRIPTION
7 7
8#################################################################### 8 ####################################################################
9# 9 #
10# This file implements an easy way of creating new functions that 10 # This file implements an easy way of creating new functions that
11# are added to the current Parser context. (This avoids having to 11 # are added to the current Parser context. (This avoids having to
12# do the complicated procedure outlined in the docs/parser/extensions 12 # do the complicated procedure outlined in the docs/parser/extensions
13# samples.) 13 # samples.)
14# 14 #
15# To create a function that can be used in Formula() calls (and by 15 # To create a function that can be used in Formula() calls (and by
16# students in their answers), use the parserFunction() routine, as 16 # students in their answers), use the parserFunction() routine, as
17# in the following examples: 17 # in the following examples:
18# 18 #
19# parserFunction(f => "sqrt(x+1)-2"); 19 # parserFunction(f => "sqrt(x+1)-2");
20# 20 #
21# $x = Formula('x'); 21 # $x = Formula('x');
22# parserFunction(f => sqrt($x+1)-2); 22 # parserFunction(f => sqrt($x+1)-2);
23# 23 #
24# parserFunction("f(x)" => "sqrt(x+1)-2"); 24 # parserFunction("f(x)" => "sqrt(x+1)-2");
25# 25 #
26# parserFunction("f(x,y)" => "sqrt(x*y)"); 26 # parserFunction("f(x,y)" => "sqrt(x*y)");
27# 27 #
28# The first parameter to parserFunction is the name of the function 28 # The first parameter to parserFunction is the name of the function
29# or the name with its argument list. In the first case, the 29 # or the name with its argument list. In the first case, the
30# names of the variables are taken from the formula for the 30 # names of the variables are taken from the formula for the
31# function, and are listed in alphabetical order. 31 # function, and are listed in alphabetical order.
32# 32 #
33# The second argument is the formula used to compute the value 33 # The second argument is the formula used to compute the value
34# of the function. It can be either a string or a Parser Formula 34 # of the function. It can be either a string or a Parser Formula
35# object. 35 # object.
36# 36 #
37 37
38=cut 38=cut
39 39
40sub parserFunction {parserFunction->Create(@_)} 40sub parserFunction {parserFunction->Create(@_)}
41 41

Legend:
Removed from v.5372  
changed lines
  Added in v.5373

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9