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

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

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

Revision 5373 Revision 5392
1loadMacros('MathObjects.pl'); 1loadMacros('MathObjects.pl');
2 2
3sub _contextIntegerFunctions_init {}; # don't reload this file 3sub _contextIntegerFunctions_init {context::IntegerFunctions2::Init()}; # don't reload this file
4 4
5=head3 Context("IntegerFunctions") 5=head3 Context("IntegerFunctions")
6 6
7 ###################################################################### 7 ######################################################################
8 # 8 #
23 # Note: If the context is set to something else, such as Numeric, it 23 # Note: If the context is set to something else, such as Numeric, it
24 # can be set back with Context("IntegerFunctions"). 24 # can be set back with Context("IntegerFunctions").
25 25
26=cut 26=cut
27 27
28$context{IntegerFunctions} = Parser::Context->getCopy("Numeric");
29
30package IntegerFunction2; 28package context::IntegerFunction2;
31our @ISA = qw(Parser::Function::numeric2); # checks for 2 numeric inputs 29our @ISA = qw(Parser::Function::numeric2); # checks for 2 numeric inputs
32 30
33sub C { 31sub C {
34 shift; my ($n,$r) = @_; my $C = 1; 32 shift; my ($n,$r) = @_; my $C = 1;
35 return (0) if($r>$n); 33 return (0) if($r>$n);
43 return (0) if($r>$n); 41 return (0) if($r>$n);
44 for (1..$r) {$P *= ($n-$_+1)} 42 for (1..$r) {$P *= ($n-$_+1)}
45 return $P 43 return $P
46} 44}
47 45
48package main; 46sub Init {
47 my $context = $main::context{IntegerFunctions} = Parser::Context->getCopy("Numeric");
49 48
50$context{'IntegerFunctions'}->functions->add( 49 $context->functions->add(
51 C => {class => 'IntegerFunction2'}, 50 C => {class => 'context::IntegerFunction2'},
52 P => {class => 'IntegerFunction2'}, 51 P => {class => 'context::IntegerFunction2'},
53); 52 );
54 53
55Context("IntegerFunctions"); 54 main::Context("IntegerFunctions");
55}
56 56
571; 571;

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9