mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-10 11:45:45 +03:00
lib: add xor
This gets clumsily reimplemented in various places, to no useful end.
This commit is contained in:
parent
d03a448222
commit
725bb4e48c
12 changed files with 49 additions and 38 deletions
|
@ -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”
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue