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 = (
|
||||
'add' => sub {
|
||||
'+' => sub {
|
||||
my $sum = 0;
|
||||
$sum += $_ foreach (@_);
|
||||
return $sum;
|
||||
},
|
||||
'sub' => sub {
|
||||
'-' => sub {
|
||||
my $sum = shift;
|
||||
$sum -= $_ foreach (@_);
|
||||
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;
|
||||
print "$e\n";
|
||||
return undef;
|
||||
|
|
Loading…
Reference in a new issue