Handbook
Glossary
all-subsets ( seq -- subsets )
Vocabulary
math
.
combinatorics
Inputs
seq
a
sequence
Outputs
subsets
a
sequence
Word description
Returns all the subsets of a sequence.
Examples
USING: math.combinatorics prettyprint ; { 1 2 3 } all-subsets .
{ { } { 1 } { 2 } { 3 } { 1 2 } { 1 3 } { 2 3 } { 1 2 3 } }
Definition
USING:
kernel
ranges
sequences
;
IN:
math.combinatorics
:
all-subsets
( seq -- subsets )
dup
length
[0..b]
[
all-combinations
]
with
map
concat
;