<A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (
self: Iterable<A>
) => Iterable<C>
<A, B, C>(
self: Iterable<A>,
that: Iterable<B>,
f: (a: A, b: B) => C
): Iterable<C>Zips this Iterable crosswise with the specified Iterable using the specified combiner.
Example (Combining cartesian products)
import { Iterable } from "effect"
// Create coordinate pairs
const xs = [1, 2]
const ys = ["a", "b", "c"]
const coordinates = Iterable.cartesianWith(xs, ys, (x, y) => `(${x},${y})`)
console.log(Array.from(coordinates)) // ["(1,a)", "(1,b)", "(1,c)", "(2,a)", "(2,b)", "(2,c)"]
// Generate all combinations of options
const sizes = ["S", "M", "L"]
const colors = ["red", "blue"]
const products = Iterable.cartesianWith(
sizes,
colors,
(size, color) => ({ size, color })
)
console.log(Array.from(products))
// [
// { size: "S", color: "red" }, { size: "S", color: "blue" },
// { size: "M", color: "red" }, { size: "M", color: "blue" },
// { size: "L", color: "red" }, { size: "L", color: "blue" }
// ]
// Mathematical operations on all pairs
const a = [1, 2, 3]
const b = [10, 20]
const mathProducts = Iterable.cartesianWith(a, b, (x, y) => x * y)
console.log(Array.from(mathProducts)) // [10, 20, 20, 40, 30, 60]
// Create test data combinations
const userTypes = ["admin", "user"]
const features = ["read", "write", "delete"]
const testCases = Iterable.cartesianWith(
userTypes,
features,
(user, feature) => `${user}_can_${feature}`
)
console.log(Array.from(testCases))
// ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]elements
Source effect/Iterable.ts:23918 lines
export const const cartesianWith: {
<A, B, C>(
that: Iterable<B>,
f: (a: A, b: B) => C
): (self: Iterable<A>) => Iterable<C>
<A, B, C>(
self: Iterable<A>,
that: Iterable<B>,
f: (a: A, b: B) => C
): Iterable<C>
}
Zips this Iterable crosswise with the specified Iterable using the specified combiner.
Example (Combining cartesian products)
import { Iterable } from "effect"
// Create coordinate pairs
const xs = [1, 2]
const ys = ["a", "b", "c"]
const coordinates = Iterable.cartesianWith(xs, ys, (x, y) => `(${x},${y})`)
console.log(Array.from(coordinates)) // ["(1,a)", "(1,b)", "(1,c)", "(2,a)", "(2,b)", "(2,c)"]
// Generate all combinations of options
const sizes = ["S", "M", "L"]
const colors = ["red", "blue"]
const products = Iterable.cartesianWith(
sizes,
colors,
(size, color) => ({ size, color })
)
console.log(Array.from(products))
// [
// { size: "S", color: "red" }, { size: "S", color: "blue" },
// { size: "M", color: "red" }, { size: "M", color: "blue" },
// { size: "L", color: "red" }, { size: "L", color: "blue" }
// ]
// Mathematical operations on all pairs
const a = [1, 2, 3]
const b = [10, 20]
const mathProducts = Iterable.cartesianWith(a, b, (x, y) => x * y)
console.log(Array.from(mathProducts)) // [10, 20, 20, 40, 30, 60]
// Create test data combinations
const userTypes = ["admin", "user"]
const features = ["read", "write", "delete"]
const testCases = Iterable.cartesianWith(
userTypes,
features,
(user, feature) => `${user}_can_${feature}`
)
console.log(Array.from(testCases))
// ["admin_can_read", "admin_can_write", "admin_can_delete", "user_can_read", "user_can_write", "user_can_delete"]
cartesianWith: {
<function (type parameter) A in <A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>A, function (type parameter) B in <A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>B, function (type parameter) C in <A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>C>(that: Iterable<B>that: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) B in <A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>B>, f: (a: A, b: B) => Cf: (a: Aa: function (type parameter) A in <A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>A, b: Bb: function (type parameter) B in <A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>B) => function (type parameter) C in <A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>C): (self: Iterable<A>self: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>A>) => interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) C in <A, B, C>(that: Iterable<B>, f: (a: A, b: B) => C): (self: Iterable<A>) => Iterable<C>C>
<function (type parameter) A in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>A, function (type parameter) B in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>B, function (type parameter) C in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>C>(self: Iterable<A>self: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>A>, that: Iterable<B>that: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) B in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>B>, f: (a: A, b: B) => Cf: (a: Aa: function (type parameter) A in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>A, b: Bb: function (type parameter) B in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>B) => function (type parameter) C in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>C): interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) C in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>C>
} = import dualdual(
3,
<function (type parameter) A in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>A, function (type parameter) B in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>B, function (type parameter) C in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>C>(self: Iterable<A>self: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) A in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>A>, that: Iterable<B>that: interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) B in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>B>, f: (a: A, b: B) => Cf: (a: Aa: function (type parameter) A in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>A, b: Bb: function (type parameter) B in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>B) => function (type parameter) C in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>C): interface Iterable<T, TReturn = any, TNext = any>Iterable<function (type parameter) C in <A, B, C>(self: Iterable<A>, that: Iterable<B>, f: (a: A, b: B) => C): Iterable<C>C> =>
const flatMap: {
<A, B>(
f: (a: NoInfer<A>, i: number) => Iterable<B>
): (self: Iterable<A>) => Iterable<B>
<A, B>(
self: Iterable<A>,
f: (a: NoInfer<A>, i: number) => Iterable<B>
): Iterable<B>
}
flatMap(self: Iterable<A>self, (a: NoInfer<A>a) => const map: {
<A, B>(f: (a: NoInfer<A>, i: number) => B): (
self: Iterable<A>
) => Iterable<B>
<A, B>(
self: Iterable<A>,
f: (a: NoInfer<A>, i: number) => B
): Iterable<B>
}
map(that: Iterable<B>that, (b: NoInfer<B>b) => f: (a: A, b: B) => Cf(a: NoInfer<A>a, b: NoInfer<B>b)))
)Referenced by 1 symbols