Add logical operations

This commit is contained in:
madmaurice 2021-04-02 03:35:59 +02:00
parent 512977011b
commit 395c271243

View file

@ -107,7 +107,19 @@ my %stdctx = (
'oddp' => sub { my ($a) = @_; return ($a % 2 != 0); },
'eq' => sub { my ($a, $b) = @_; return ($a == $b); },
'ne' => sub { my ($a, $b) = @_; return ($a != $b); },
# Logical operators
'not' => sub { my ($a) = @_; return !$a; },
'and' => sub {
my $v = 1;
$v &&= $_ foreach (@_);
return $v;
},
'or' => sub {
my $v = 0;
$v ||= $_ foreach(@_);
return $v;
},
# Numeric comparison
'=' => sub { my ($a, $b) = @_; return ($a == $b); },