aboutsummaryrefslogtreecommitdiff
path: root/aoc-2020-gleam/src/ext/boolx.gleam
diff options
context:
space:
mode:
Diffstat (limited to 'aoc-2020-gleam/src/ext/boolx.gleam')
-rw-r--r--aoc-2020-gleam/src/ext/boolx.gleam10
1 files changed, 10 insertions, 0 deletions
diff --git a/aoc-2020-gleam/src/ext/boolx.gleam b/aoc-2020-gleam/src/ext/boolx.gleam
new file mode 100644
index 0000000..f3c8b49
--- /dev/null
+++ b/aoc-2020-gleam/src/ext/boolx.gleam
@@ -0,0 +1,10 @@
+pub fn guard_lazy(
+ when requirement: Bool,
+ return consequence: fn() -> t,
+ otherwise alternative: fn() -> t,
+) -> t {
+ case requirement {
+ True -> consequence()
+ False -> alternative()
+ }
+}