MCPcopy Create free account
hub / github.com/Effect-TS/effect / visit

Function visit

packages/effect/test/Hash.test.ts:31–39  ·  view source on GitHub ↗
(prefix: ReadonlyArray<A>, remaining: ReadonlyArray<A>)

Source from the content-addressed store, hash-verified

29const permutations = <A>(values: ReadonlyArray<A>): ReadonlyArray<ReadonlyArray<A>> => {
30 const output: Array<ReadonlyArray<A>> = []
31 const visit = (prefix: ReadonlyArray<A>, remaining: ReadonlyArray<A>): void => {
32 if (remaining.length === 0) {
33 output.push(prefix)
34 return
35 }
36 for (let i = 0; i < remaining.length; i++) {
37 visit([...prefix, remaining[i]], [...remaining.slice(0, i), ...remaining.slice(i + 1)])
38 }
39 }
40 visit([], values)
41 return output
42}

Callers 2

permutationsFunction · 0.70
Graph.test.tsFile · 0.70

Calls 2

sliceMethod · 0.80
pushMethod · 0.65

Tested by

no test coverage detected