foldLeftProduct

inline fun <T, S, C> List<S>.foldLeftProduct(initialContext: C, crossinline map: (C, S) -> Iterator<Pair<C, T>>): Iterable<List<T>>

Constructs a cartesian product of the given ordered list of source elements, by computing the Iterable via a mapping function with a context. The mapping function constructs an Iterator of Pair instances of C and S that are used to derive subsequent iterators.

Parameters

initialContext

The initial context to map/fold with.

map

The mapping function to convert S to Iterable of T with the folded context.

T

The element type of the product.

S

The source type of the list to be map and folded upon.

C

The context to map and fold over S.