Add more std functions
This commit is contained in:
parent
b6eea1138e
commit
72141ffde6
1 changed files with 13 additions and 3 deletions
|
@ -77,17 +77,27 @@ sub tokenize {
|
||||||
}
|
}
|
||||||
|
|
||||||
my %stdctx = (
|
my %stdctx = (
|
||||||
'add' => sub {
|
'+' => sub {
|
||||||
my $sum = 0;
|
my $sum = 0;
|
||||||
$sum += $_ foreach (@_);
|
$sum += $_ foreach (@_);
|
||||||
return $sum;
|
return $sum;
|
||||||
},
|
},
|
||||||
'sub' => sub {
|
'-' => sub {
|
||||||
my $sum = shift;
|
my $sum = shift;
|
||||||
$sum -= $_ foreach (@_);
|
$sum -= $_ foreach (@_);
|
||||||
return $sum;
|
return $sum;
|
||||||
},
|
},
|
||||||
'print' => sub {
|
'*' => sub {
|
||||||
|
my $prod = 1;
|
||||||
|
$prod *= $_ foreach(@_);
|
||||||
|
return $prod;
|
||||||
|
},
|
||||||
|
'/' => sub {
|
||||||
|
my $quot = shift;
|
||||||
|
$quot /= $_ foreach(@_);
|
||||||
|
return $quot;
|
||||||
|
},
|
||||||
|
'write-line' => sub {
|
||||||
my $e = shift;
|
my $e = shift;
|
||||||
print "$e\n";
|
print "$e\n";
|
||||||
return undef;
|
return undef;
|
||||||
|
|
Loading…
Reference in a new issue