lib: add xor
This gets clumsily reimplemented in various places, to no useful end.
This commit is contained in:
@@ -199,6 +199,24 @@ in {
|
||||
*/
|
||||
and = x: y: x && y;
|
||||
|
||||
/**
|
||||
boolean “exclusive or”
|
||||
|
||||
|
||||
# Inputs
|
||||
|
||||
`x`
|
||||
|
||||
: 1\. Function argument
|
||||
|
||||
`y`
|
||||
|
||||
: 2\. Function argument
|
||||
*/
|
||||
# We explicitly invert the arguments purely as a type assertion.
|
||||
# This is invariant under XOR, so it does not affect the result.
|
||||
xor = x: y: (!x) != (!y);
|
||||
|
||||
/**
|
||||
bitwise “not”
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user