inverse-permutation ( seq -- permutation )


Vocabulary
math.combinatorics

Inputs
seqa sequence


Outputs
permutationa sequence


Word description
Outputs a sequence of indices representing the lexicographical permutation of seq.

Notes
All items in seq must be comparable by <=>.

Examples
USING: math.combinatorics prettyprint ; "dcba" inverse-permutation .
{ 3 2 1 0 }

USING: math.combinatorics prettyprint ; { 12 56 34 78 } inverse-permutation .
{ 0 2 1 3 }


Definition