 <PRIVATE
 
 : find-max-index ( seq n -- i )
-    over length - '[ _ + >= ] find-index drop ;
+    over length - '[ _ + >= ] find-index drop ; inline
 
 : increment-rest ( i seq -- )
     [ nth ] [ swap tail-slice ] 2bi
-    [ drop 1 + dup ] map! 2drop ;
+    [ drop 1 + dup ] map! 2drop ; inline
 
 : increment-last ( seq -- )
-    [ [ length 1 - ] keep [ 1 + ] change-nth ] unless-empty ;
+    [ [ length 1 - ] keep [ 1 + ] change-nth ] unless-empty ; inline
 
 :: next-combination ( seq n -- seq )
     seq n find-max-index [

        seq increment-last
    ] if* seq ;

:: combinations-quot ( seq k quot -- seq quot' )
    seq length :> n
    n k nCk iota k iota >array seq quot n

! See http://factorcode.org/license.txt for BSD license.

USING: accessors arrays assocs binary-search classes.tuple fry
hints kernel locals math math.order math.ranges memoize
namespaces sequences sequences.private sorting ;
FROM: sequences => change-nth ;
IN: math.combinatorics

