Add bitwise operations
This commit is contained in:
parent
af9a6acd53
commit
106a58991d
1 changed files with 27 additions and 0 deletions
|
@ -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,
|
||||||
|
|
Loading…
Reference in a new issue