Skip to content

Commit

Permalink
Simplify list.allHelper(…)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasWanke committed Dec 19, 2024
1 parent fba96b8 commit 9772291
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages_v5/example.candy
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,12 @@ fun all[T](list: List[T], predicate: (T) Bool) Bool {
list.allHelper(predicate, 0)
}
fun allHelper[T](list: List[T], predicate: (T) Bool, index: Int) Bool {
switch index.isLessThan(list.length()) {
true => switch predicate(list.get(index).unwrap()) {
switch list.get(index) {
some(item) => switch predicate(item) {
true => list.allHelper(predicate, index.add(1)),
false => false,
},
false => true,
none => true,
}
}
fun any[T](list: List[T], predicate: (T) Bool) Bool {
Expand Down

0 comments on commit 9772291

Please sign in to comment.