lib: add xor

This gets clumsily reimplemented in various places, to no useful end.
This commit is contained in:
edef 2024-04-04 14:05:18 +00:00
parent d03a448222
commit 725bb4e48c
12 changed files with 49 additions and 38 deletions

View file

@ -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
*/