UNPKG
fcircuit-core
Version:
latest (1.1.2)
1.1.2
1.1.1
1.1.0
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
Core library for functional circuit modeling and simulation.
fcircuit-core
/
src
/
utils
/
generate-combinations.js
14 lines
(13 loc)
•
358 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
12
13
14
export
const
generateCombinations
= (
length
) => {
const
result = []
const
generate
= (
current, depth
) => {
if
(depth === length) { result.
push
(current)
return
}
generate
([...current,
0
], depth +
1
)
generate
([...current,
1
], depth +
1
) }
generate
([],
0
)
return
result }