diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gleam/bool.gleam | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/gleam/bool.gleam b/src/gleam/bool.gleam index 4a9cebf..e5b079f 100644 --- a/src/gleam/bool.gleam +++ b/src/gleam/bool.gleam @@ -30,6 +30,31 @@ pub fn negate(bool: Bool) -> Bool { } } +/// Returns the exclusive or of two bools +/// +/// ## Examples +/// +/// > exclusive_or(False, False) +/// False +/// +/// > exclusive_or(False, True) +/// True +/// +/// > exclusive_or(True, False) +/// True +/// +/// > exclusive_or(True, True) +/// False +/// +pub fn exclusive_or(a: Bool, b: Bool) -> Bool { + case a, b { + False, False -> False + False, True -> True + True, False -> True + True, True -> False + } +} + /// Compares two bools and returns the first values Order to the second. /// /// ## Examples |