diff --git a/lib/Minilisp.pm b/lib/Minilisp.pm index b1886be..7eb2269 100644 --- a/lib/Minilisp.pm +++ b/lib/Minilisp.pm @@ -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;