From e3178fb8d056b2e55f0baa041be313d9c4bd1ff4 Mon Sep 17 00:00:00 2001 From: Quinn Wilton Date: Wed, 2 Dec 2020 11:33:39 -0800 Subject: Add bool.exclusive_nor --- src/gleam/bool.gleam | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'src') 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 -- cgit v1.2.3