all-permutations ( seq -- seq' ) (original) (raw)

all-permutations ( seq -- seq' )

Vocabulary
math.combinatorics

Inputs

seq a sequence

Outputs

seq' a sequence

Word description
Outputs a sequence containing all permutations of seq in lexicographical order.

Examples

USING: math.combinatorics prettyprint ; { 0 1 2 } all-permutations .
{ { 0 1 2 } { 0 2 1 } { 1 0 2 } { 1 2 0 } { 2 0 1 } { 2 1 0 } }

Definition

IN: math.combinatorics

: all-permutations ( seq -- seq' ) [ ] map-permutations ;