lily/docs/spec/iter.md
koniifer 33cf8d7209 iterator work
improve performance of split, chars, chars_ref
properly implement lily.iter.Iterator.fold
partially implement lily.iter.Iterator.collect
fix lily.iter.Skip logic
code cleanup
write proposed iterator spec
2025-01-18 18:49:46 +00:00

594 B

iterators

spec to-be-defined

proposed spec:

.{IterNext, Iterator} := @use("lily").iter

Iterable := struct {
    // ! required
    // IterNext == struct { finished: bool, val: T }
    next := fn(self: ^Self): IterNext(T)
    into_iter := fn(self: Self): Iterator(Self)
    // ! proposed
    // addition of these two would allow for cheap implementation of `skip`, and `nth` in lily.iter.Iterator
    peek := fn(self: ^Self): IterNext(T)
    advance := fn(self: ^Self, n: uint): IterNext(T)
    // ! proposed (waiting on compiler)
    iter := fn(self: ^Self): Iterator(^Self)
}