blob: 8e34351bbb7ad6f9b2877db14c61059325e43f06 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
|
import gleam/iterator.{Iterator} as iter
import gleam/list
pub fn length(iterator: Iterator(a)) -> Int {
iterator
|> iter.fold(from: 0, with: fn(c, _) { c + 1 })
}
pub fn count(iterator: Iterator(a), satisfying predicate: fn(a) -> Bool) -> Int {
iterator
|> iter.filter(for: predicate)
|> length
}
|