mirror of
https://github.com/kanaka/mal.git
synced 2024-11-11 00:52:44 +03:00
b8ee29b22f
Also, fix nth and count to match cloure.
34 lines
454 B
Perl
34 lines
454 B
Perl
use strict;
|
|
use warnings FATAL => qw(all);
|
|
use readline qw(readline);
|
|
|
|
# read
|
|
sub READ {
|
|
my $str = shift;
|
|
return $str;
|
|
}
|
|
|
|
# eval
|
|
sub EVAL {
|
|
my($ast, $env) = @_;
|
|
return eval($ast);
|
|
}
|
|
|
|
# print
|
|
sub PRINT {
|
|
my $exp = shift;
|
|
return $exp;
|
|
}
|
|
|
|
# repl
|
|
sub REP {
|
|
my $str = shift;
|
|
return PRINT(EVAL(READ($str), {}));
|
|
}
|
|
|
|
while (1) {
|
|
my $line = readline("user> ");
|
|
if (! defined $line) { last; }
|
|
print(REP($line), "\n");
|
|
}
|