itertools#

itertools provides various utilities which simplify the composition of generators and collectors.

define drain

A constant of type Collector.

type iterbits

An opaque type of supertype OverloadedFunction.

inline parameter-defaults ()
inline templates ( value )
inline ->> ( generator collector... )
inline bitdim ( x n... )

A variant of dim optimized for power of two sizes; the dimensions are specified as exponents of 2.

inline cascade ( collector... )

Two collectors:

  • Every time a is full, b collects a and a is reset.
  • When b ends, the remainder of a is collected.
inline cat ( coll )

Treat input as a generator and forward its arguments individually.

inline closest ( gen n fcmp )

return the n closest elements in gen using comparison operator fcmp

inline collect ( coll )

Run collector until full and return the result.

inline demux ( init-value f collector... )

A reducing sink for mux streams.

inline dim ( x n... )

A branchless generator that iterates multidimensional coordinates.

inline each ( generator collector )

Fold output from generator into collector.

inline filter ( f coll )
inline flatten ( coll )

Collect variadic input as individual single items.

inline gate ( f a b )

If f is true, collect input in a, otherwise collect in b. When both are full, output both. Until both are full, new input for full containers is discarded.

inline imap ( gen f )
inline ipair ( gen N )

Generate one variadic argument from N generated arguments.

inline limit ( f coll )
inline map ( f coll )
inline mux ( collector... )

Send input into multiple collectors which each fork the target collector.

inline permutate-range ( n element-type )

Return a generator that iterates all permutations of the range from 0 to n, where n must be smaller than 256, and returns a vector of element-type for each iteration. If element-type is omitted, the default element type will be i32.

The generator will perform n! iterations to complete.

inline reduce ( init f )
inline retain ( mapl ... )

Feeds the input through a composition of collectors and feeds the input along with the composition output to the next collector. If mapl is not none, it allows specifying the portion of the input that will be passed to the end point.

inline take ( n coll )

Limit collector to output n items.

spice compose ( ... )
spice join ( ... )
spice span ( ... )
spice va-ordered-insert ( ... )
spice zip ( ... )