aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQuinn Wilton <wilton@synopsys.com>2020-12-02 11:29:02 -0800
committerLouis Pilfold <louis@lpil.uk>2020-12-02 20:13:15 +0000
commit32d9d1622940323ec41ae991a62cf82427e16561 (patch)
tree0a495f2eba0f098848de59d1814b7dca7095dffa /src
parentf040d1a317604c6f0c8e14b4149c5fd6771ada90 (diff)
downloadgleam_stdlib-32d9d1622940323ec41ae991a62cf82427e16561.tar.gz
gleam_stdlib-32d9d1622940323ec41ae991a62cf82427e16561.zip
Add bool.exclusive_or
Diffstat (limited to 'src')
-rw-r--r--src/gleam/bool.gleam25
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