aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMarcin Puc <marcin.e.puc@gmail.com>2021-03-27 13:45:49 +0100
committerLouis Pilfold <louis@lpil.uk>2021-03-28 20:59:55 +0100
commitf57e7091f127101d065999834e44f3059e63b3ec (patch)
tree172fc09c05ec34ba22887827ed8b7e79fd8eb10d /src
parenta57e5ce8385cc2b892c3c2292caf56e686d02222 (diff)
downloadgleam_stdlib-f57e7091f127101d065999834e44f3059e63b3ec.tar.gz
gleam_stdlib-f57e7091f127101d065999834e44f3059e63b3ec.zip
Simplify list.{any, all}
Diffstat (limited to 'src')
-rw-r--r--src/gleam/list.gleam12
1 files changed, 2 insertions, 10 deletions
diff --git a/src/gleam/list.gleam b/src/gleam/list.gleam
index 1fddc84..7df9862 100644
--- a/src/gleam/list.gleam
+++ b/src/gleam/list.gleam
@@ -635,11 +635,7 @@ pub fn find_map(
pub fn all(in list: List(a), satisfying predicate: fn(a) -> Bool) -> Bool {
case list {
[] -> True
- [x, ..rest] ->
- case predicate(x) {
- True -> all(rest, predicate)
- _ -> False
- }
+ [x, ..rest] -> predicate(x) && all(rest, predicate)
}
}
@@ -664,11 +660,7 @@ pub fn all(in list: List(a), satisfying predicate: fn(a) -> Bool) -> Bool {
pub fn any(in list: List(a), satisfying predicate: fn(a) -> Bool) -> Bool {
case list {
[] -> False
- [x, ..rest] ->
- case predicate(x) {
- False -> any(rest, predicate)
- _ -> True
- }
+ [x, ..rest] -> predicate(x) || any(rest, predicate)
}
}