From 512977011ba0f3c6cd386c645568ae84543a705c Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Fri, 2 Apr 2021 03:10:24 +0200 Subject: [PATCH] Reorder functions --- lib/Minilisp.pm | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/Minilisp.pm b/lib/Minilisp.pm index da7134d..8e635c5 100644 --- a/lib/Minilisp.pm +++ b/lib/Minilisp.pm @@ -105,10 +105,19 @@ my %stdctx = ( 'null' => sub { my ($a) = @_; return ! defined $a; }, 'evenp' => sub { my ($a) = @_; return ($a % 2 == 0); }, 'oddp' => sub { my ($a) = @_; return ($a % 2 != 0); }, - 'eq' => sub { my ($a, $b) = @_; return ($a eq $b); }, - 'ne' => sub { my ($a, $b) = @_; return ($a ne $b); }, - '==' => sub { my ($a, $b) = @_; return ($a == $b); }, - '!=' => sub { my ($a, $b) = @_; return ($a != $b); }, + 'eq' => sub { my ($a, $b) = @_; return ($a == $b); }, + 'ne' => sub { my ($a, $b) = @_; return ($a != $b); }, + 'not' => sub { my ($a) = @_; return !$a; }, + + # Numeric comparison + '=' => sub { my ($a, $b) = @_; return ($a == $b); }, + '/=' => sub { my ($a, $b) = @_; return ($a != $b); }, + '>' => sub { my ($a,$b) = @_; return ($a > $b); }, + '<' => sub { my ($a,$b) = @_; return ($a < $b); }, + '>=' => sub { my ($a,$b) = @_; return ($a >= $b); }, + '<=' => sub { my ($a,$b) = @_; return ($a <= $b); }, + + # String comparison 'string=' => sub { my ($a, $b) = @_; return ($a eq $b); }, 'string/=' => sub { my ($a, $b) = @_; return ($a ne $b); }, 'string<' => sub { my ($a, $b) = @_; return ($a lt $b); }, @@ -121,11 +130,8 @@ my %stdctx = ( 'string-greaterp' => sub { my ($a, $b) = @_; return (lc($a) gt lc($b)); }, 'string-not-greaterp' => sub { my ($a, $b) = @_; return !(lc($a) gt lc($b)); }, 'string-not-lessp' => sub { my ($a, $b) = @_; return !(lc($a) lt lc($b)); }, - '>' => sub { my ($a,$b) = @_; return ($a > $b); }, - '<' => sub { my ($a,$b) = @_; return ($a < $b); }, - '>=' => sub { my ($a,$b) = @_; return ($a >= $b); }, - '<=' => sub { my ($a,$b) = @_; return ($a <= $b); }, - 'not' => sub { my ($a) = @_; return !$a; }, + + # Constants 't' => 1, 'f' => 0, 'nil' => undef,