An enumeration provides a view of a sequence as an assoc mapping integer indices to elements:
enumerated
<enumerated> ( seq -- enumerated )
Inverting a permutation using enumerations:
IN: scratchpad
: invert ( perm -- perm' )
<enumerated> sort-values keys ;
{ 2 0 4 1 3 } invert .
{ 1 3 0 4 2 }