Short, dead simple and concise generic iterator interface. With a few extras similar to what python has to offer.
$ go get -u github.com/0x5a17ed/itkit@latest
package main
import (
"fmt"
"github.com/0x5a17ed/itkit/iters/sliceit"
"github.com/0x5a17ed/itkit/itlib"
)
func main() {
s := []int{1, 2, 3}
// iterating using the for keyword.
for it := sliceit.In(s); it.Next(); {
fmt.Println(it.Value())
}
// iterating using a slightly more functional approach.
itlib.Apply(sliceit.In(s), func(v int) {
fmt.Println(v)
})
}
The iterator interface is desgined after the stateful iterators pattern explained in the brilliant blog post from https://ewencp.org/blog/golang-iterators/index.html. Most functions to manipulate iterators draw inspiration from different sources such as Python and github.com/samber/lo.
itkit is licensed under the Apache License, Version 2.0.
yes.