// tracing: off
import * as A from "../../Collections/Immutable/Array"
import { pipe } from "../../Function"
import { flattenTuples } from "./_internal/flattenTuples"
import { cross_ } from "./cross"
import { map } from "./map"
/**
 * Composes the specified streams to create a cartesian product of elements
 * with a specified function. Subsequent streams would be run multiple times,
 * for every combination of elements in the prior streams.
 *
 * See also `Stream#zipN` for the more common point-wise variant.
 */

export function crossN(...[s1, s2, ...streams]) {
  return (f) => {
    return map((_) => f(...flattenTuples(_)))(
      A.reduce_(streams, cross_(s1, s2), cross_)
    )
  }
}
//# sourceMappingURL=crossN.js.map
