Add logical operations
This commit is contained in:
parent
512977011b
commit
395c271243
1 changed files with 12 additions and 0 deletions
|
@ -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); },
|
||||
|
|
Loading…
Reference in a new issue