From b0d9bf447ec2e731f71bea39021ce836b502177b Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Sat, 3 Apr 2021 18:47:23 +0200 Subject: [PATCH] Move length to multipurpose functions --- lib/Minilisp.pm | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/lib/Minilisp.pm b/lib/Minilisp.pm index dfce759..574e246 100644 --- a/lib/Minilisp.pm +++ b/lib/Minilisp.pm @@ -227,20 +227,6 @@ my %stdctx = ( '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)); }, - # string length - 'length' => sub { - my ($a) = @_; - - if (ref($a) eq "ARRAY") - { - return scalar(@$a); - } - else - { - return length($a); - } - }, - # Bitwise operations 'logand' => sub { my $v = -1; @@ -312,6 +298,18 @@ my %stdctx = ( # Multi-purpose 'equal' => \&lisp_equal, + 'length' => sub { + my ($a) = @_; + + if (ref($a) eq "ARRAY") + { + return scalar(@$a); + } + else + { + return length($a); + } + }, ); sub parser {