diff options
author | inoas <mail@inoas.com> | 2022-06-27 23:05:05 +0200 |
---|---|---|
committer | Louis Pilfold <louis@lpil.uk> | 2022-07-03 22:10:45 +0100 |
commit | 443da76692bc839e42e9c65e0f4d125270d1d9bf (patch) | |
tree | 5abd4fb68e0c529bcf10de7aadab1e36f4cc817c | |
parent | 957b0dd730b16270c6d2b783825b629858571879 (diff) | |
download | gleam_stdlib-443da76692bc839e42e9c65e0f4d125270d1d9bf.tar.gz gleam_stdlib-443da76692bc839e42e9c65e0f4d125270d1d9bf.zip |
revert boolean + execution on of predicate, enable short circuit path
-rw-r--r-- | src/gleam/list.gleam | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam index 38a6607..6977338 100644 --- a/src/gleam/list.gleam +++ b/src/gleam/list.gleam @@ -796,9 +796,9 @@ pub fn all(in list: List(a), satisfying predicate: fn(a) -> Bool) -> Bool { fn do_all(list: List(a), predicate: fn(a) -> Bool, accumulator: Bool) -> Bool { case list { - // _ if accumulator == False -> False + _ if accumulator == False -> False [] -> accumulator - [x, ..rest] -> do_all(rest, predicate, accumulator && predicate(x)) + [x, ..rest] -> do_all(rest, predicate, predicate(x) && accumulator) } } @@ -831,9 +831,9 @@ pub fn any(in list: List(a), satisfying predicate: fn(a) -> Bool) -> Bool { fn do_any(list: List(a), predicate: fn(a) -> Bool, accumulator: Bool) -> Bool { case list { - // _ if accumulator == True -> True + _ if accumulator == True -> True [] -> accumulator - [x, ..rest] -> do_any(rest, predicate, accumulator || predicate(x)) + [x, ..rest] -> do_any(rest, predicate, predicate(x) || accumulator) } } |