Documentation
¶
Overview ¶
Package Enumerator is a lazy sequence composite in the spirit of Ruby's Enumerator::Lazy. Transforms (Map/Filter/Take) are lazy — they wrap a producer and evaluate nothing until a terminal operation (ToArray/Each/ First/Reduce) pulls items through. This makes it safe to Take a finite prefix of an infinite Generate source.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface {
// Lazy transforms — return a new Enumerator, evaluate nothing.
Map(fn func(interface{}) interface{}) Interface
Filter(pred func(interface{}) bool) Interface
Take(n int) Interface
// Terminal operations — force evaluation.
ToArray() Array.Interface
Each(fn func(interface{}) Result.Interface) Result.Interface
First() Result.Interface
Reduce(seed interface{}, fn func(acc, item interface{}) Result.Interface) Result.Interface
IsNull() bool
}
Interface is the lazy sequence contract.
func Generate ¶
func Generate(seed interface{}, fn func(interface{}) interface{}) Interface
Generate builds an INFINITE Enumerator: seed, fn(seed), fn(fn(seed)), … It only terminates when a downstream consumer (e.g. Take/First) stops it.
Click to show internal directories.
Click to hide internal directories.