 <PRIVATE
 
 : should-swap? ( start curr seq -- ? )
-    [ nipd nth ] [ <slice> member? not ] 3bi ; inline
+    [ nipd nth-unsafe ] [ <slice-unsafe> member? not ] 3bi ; inline
 
 :: unique-permutations ( ... seq i n quot: ( ... elt -- ... ) -- ... )
     i n >= [

    over length - '[ _ + >= ] find-index drop ; inline

: increment-rest ( i seq -- )
    [ nth ] [ swap tail-slice ] 2bi
    [ drop 1 + dup ] map! 2drop ; inline

: increment-last ( seq -- )
    [ [ length 1 - ] keep [ 1 + ] change-nth ] unless-empty ; inline

:: next-combination ( seq n -- seq )
    seq n find-max-index [


<PRIVATE

: <permutation-iota> ( seq -- <iota> )
    length factorial <iota> ; inline

: permutations-quot ( seq quot -- seq quot' )
    [ [ <permutation-iota> ] [ length <iota> >array ] [ ] tri ] dip
    '[ drop _ [ _ nths-unsafe @ ] keep next-permutation drop ] ; inline

PRIVATE>
