Minor improvement to xor word
parent
c6f51c11bd
commit
9bd8e88318
|
@ -437,7 +437,7 @@ HELP: or
|
|||
|
||||
HELP: xor
|
||||
{ $values { "obj1" "a generalized boolean" } { "obj2" "a generalized boolean" } { "?" "a generalized boolean" } }
|
||||
{ $description "Tests if at exactly one object is not " { $link f } "." }
|
||||
{ $description "If exactly one input is false, outputs the other input. Otherwise outputs " { $link f } "." }
|
||||
{ $notes "This word implements boolean exclusive or, so applying it to integers will not yield useful results (all integers have a true value). Bitwise exclusive or is the " { $link bitxor } " word." } ;
|
||||
|
||||
HELP: both?
|
||||
|
|
|
@ -50,6 +50,10 @@ IN: kernel.tests
|
|||
[ f ] [ 3 f and ] unit-test
|
||||
[ 4 ] [ 4 6 or ] unit-test
|
||||
[ 6 ] [ f 6 or ] unit-test
|
||||
[ f ] [ 1 2 xor ] unit-test
|
||||
[ 1 ] [ 1 f xor ] unit-test
|
||||
[ 2 ] [ f 2 xor ] unit-test
|
||||
[ f ] [ f f xor ] unit-test
|
||||
|
||||
[ slip ] must-fail
|
||||
[ ] [ :c ] unit-test
|
||||
|
|
|
@ -173,7 +173,7 @@ GENERIC: boa ( ... class -- tuple )
|
|||
|
||||
: or ( obj1 obj2 -- ? ) dupd ? ; inline
|
||||
|
||||
: xor ( obj1 obj2 -- ? ) dup not swap ? ; inline
|
||||
: xor ( obj1 obj2 -- ? ) [ f swap ? ] when* ; inline
|
||||
|
||||
: both? ( x y quot -- ? ) bi@ and ; inline
|
||||
|
||||
|
|
Loading…
Reference in New Issue