Add bitwise operations

This commit is contained in:
madmaurice 2021-04-02 03:36:39 +02:00
parent af9a6acd53
commit 106a58991d

View file

@ -162,6 +162,33 @@ my %stdctx = (
'string-not-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)); }, 'string-not-lessp' => sub { my ($a, $b) = @_; return !(lc($a) lt lc($b)); },
# Bitwise operations
'logand' => sub {
my $v = -1;
$v &= $_ foreach (@_);
return $v;
},
'logior' => sub {
my $v = 0;
$v |= $_ foreach (@_);
return $v;
},
'logxor' => sub {
my $v = 0;
$v ^= $_ foreach (@_);
return $v;
},
'lognor' => sub {
my $v = -1;
$v |= $_ foreach (@_);
return ~$v;
},
'logeqv' => sub {
my $v = 0;
$v ^= $_ foreach (@_);
return ~$v;
},
# Constants # Constants
't' => 1, 't' => 1,
'f' => 0, 'f' => 0,