product

fun <T, U, R> Sequence<T>.product(other: Sequence<U>, combinator: (T, U) -> R): Sequence<R>

Returns the lazy Cartesian product of this sequence and other, combining each pair of elements via combinator. Equivalent to a nested for (x in this) for (y in other) yield(combinator(x, y)), except lazy: the result has this.count() * other.count() elements, but other must be safely re-iterable (e.g. backed by a List, not a one-shot generator), since it is traversed once per element of this sequence.


fun <T, U> Sequence<T>.product(other: Sequence<U>): Sequence<Pair<T, U>>

Same as product, pairing up elements into Pairs instead of combining them via a custom function.