From 11ee4d006bca2db581fb0335914d381290d583bb Mon Sep 17 00:00:00 2001 From: MadMaurice Date: Sat, 3 Apr 2021 18:47:45 +0200 Subject: [PATCH] Add some string functions --- lib/Minilisp.pm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Minilisp.pm b/lib/Minilisp.pm index 574e246..f776389 100644 --- a/lib/Minilisp.pm +++ b/lib/Minilisp.pm @@ -227,6 +227,14 @@ 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 operations + 'string-upcase' => sub { return uc(shift); }, + 'string-downcase' => sub { return lc(shift); }, + 'string-capitalize' => sub { + my $str = shift; + return $str =~ s/(\S+)/ucfirst($1)/erg; + }, + # Bitwise operations 'logand' => sub { my $v = -1;