aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSnowMarble <kraccoon@dimipay.io>2024-10-23 13:49:04 +0900
committerLouis Pilfold <louis@lpil.uk>2024-10-23 10:17:05 +0100
commit410d74f82f75534372a900f67cfb605605c4af9a (patch)
treea518af6b22bb827e26d65ad232112e3cf1d777bd
parentdd90ccf53a028bda83e7f6dcdb8bdb002ed168bf (diff)
downloadgleam_stdlib-410d74f82f75534372a900f67cfb605605c4af9a.tar.gz
gleam_stdlib-410d74f82f75534372a900f67cfb605605c4af9a.zip
enhance operator logics
-rw-r--r--src/gleam/bool.gleam33
1 files changed, 5 insertions, 28 deletions
diff --git a/src/gleam/bool.gleam b/src/gleam/bool.gleam
index 5c3f447..8551311 100644
--- a/src/gleam/bool.gleam
+++ b/src/gleam/bool.gleam
@@ -77,10 +77,7 @@ pub fn or(a: Bool, b: Bool) -> Bool {
/// ```
///
pub fn negate(bool: Bool) -> Bool {
- case bool {
- True -> False
- False -> True
- }
+ !bool
}
/// Returns the nor of two bools.
@@ -108,12 +105,7 @@ pub fn negate(bool: Bool) -> Bool {
/// ```
///
pub fn nor(a: Bool, b: Bool) -> Bool {
- case a, b {
- False, False -> True
- False, True -> False
- True, False -> False
- True, True -> False
- }
+ !{a || b}
}
/// Returns the nand of two bools.
@@ -141,12 +133,7 @@ pub fn nor(a: Bool, b: Bool) -> Bool {
/// ```
///
pub fn nand(a: Bool, b: Bool) -> Bool {
- case a, b {
- False, False -> True
- False, True -> True
- True, False -> True
- True, True -> False
- }
+ !{a && b}
}
/// Returns the exclusive or of two bools.
@@ -174,12 +161,7 @@ pub fn nand(a: Bool, b: Bool) -> Bool {
/// ```
///
pub fn exclusive_or(a: Bool, b: Bool) -> Bool {
- case a, b {
- False, False -> False
- False, True -> True
- True, False -> True
- True, True -> False
- }
+ a != b
}
/// Returns the exclusive nor of two bools.
@@ -207,12 +189,7 @@ pub fn exclusive_or(a: Bool, b: Bool) -> Bool {
/// ```
///
pub fn exclusive_nor(a: Bool, b: Bool) -> Bool {
- case a, b {
- False, False -> True
- False, True -> False
- True, False -> False
- True, True -> True
- }
+ a == b
}
/// Compares two bools and returns the first value's `Order` to the second.