MCPcopy
hub / github.com/prisma/prisma / _matrix

Function _matrix

helpers/blaze/matrix.ts:17–21  ·  view source on GitHub ↗

* Recursive function that is able to create a matrix of lists. * The algorithm is quite simple and recursively applies a map. * @example * map(lists[0], (item0) => map(lists[1], (item1) => map(lists[2], (...) => [item0, item1, ...])))

(lists: L.List<L.List<I>>, items: L.List<I> = [])

Source from the content-addressed store, hash-verified

15 * map(lists[0], (item0) => map(lists[1], (item1) => map(lists[2], (...) => [item0, item1, ...])))
16 */
17function _matrix<I>(lists: L.List<L.List<I>>, items: L.List<I> = []) {
18 if (items.length === lists.length) return items
19
20 return map(lists[items.length], (item) => _matrix(lists, [...items, item]))
21}
22
23/**
24 * Creates the cross-product of a list of lists.

Callers 1

matrixFunction · 0.85

Calls 1

mapFunction · 0.85

Tested by

no test coverage detected