     twiddle [ nPk ] keep factorial / ;
 
 : permutation ( n seq -- seq )
-    tuck permutation-indices reorder ;
+    tuck permutation-indices nths ;
 
 : all-permutations ( seq -- seq )
     [

! Copyright (c) 2007, 2008 Slava Pestov, Doug Coleman, Aaron Schaefer.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs kernel math math.order math.ranges mirrors
namespaces sequences sorting ;
IN: math.combinatorics

<PRIVATE

: permutation-indices ( n seq -- permutation )
    length [ factoradic ] dip 0 pad-left >permutation ;

PRIVATE>

: factorial ( n -- n! )
