aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorQuinn Wilton <wilton@synopsys.com>2020-12-02 11:33:39 -0800
committerLouis Pilfold <louis@lpil.uk>2020-12-02 20:13:15 +0000
commite3178fb8d056b2e55f0baa041be313d9c4bd1ff4 (patch)
tree494ca462749ee2093bc2fe07c22f1f0b6d97b9c8 /src
parent32d9d1622940323ec41ae991a62cf82427e16561 (diff)
downloadgleam_stdlib-e3178fb8d056b2e55f0baa041be313d9c4bd1ff4.tar.gz
gleam_stdlib-e3178fb8d056b2e55f0baa041be313d9c4bd1ff4.zip
Add bool.exclusive_nor
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 e5b079f..0792057 100644
--- a/src/gleam/bool.gleam
+++ b/src/gleam/bool.gleam
@@ -55,6 +55,31 @@ pub fn exclusive_or(a: Bool, b: Bool) -> Bool {
}
}
+/// Returns the exclusive nor of two bools
+///
+/// ## Examples
+///
+/// > exclusive_nor(False, False)
+/// True
+///
+/// > exclusive_nor(False, True)
+/// False
+///
+/// > exclusive_nor(True, False)
+/// False
+///
+/// > exclusive_nor(True, True)
+/// True
+///
+pub fn exclusive_nor(a: Bool, b: Bool) -> Bool {
+ case a, b {
+ False, False -> True
+ False, True -> False
+ True, False -> False
+ True, True -> True
+ }
+}
+
/// Compares two bools and returns the first values Order to the second.
///
/// ## Examples