selections ( seq n -- selections )


Vocabulary
math.combinatorics

Inputs and outputs
seqa sequence
nan integer
selectionsa sequence


Word description
Returns all the ways to take n (possibly the same) items from the sequence of items.

Examples
USING: math.combinatorics prettyprint ; { 1 2 } 2 selections .
{ { 1 1 } { 1 2 } { 2 1 } { 2 2 } }


Definition
USING: kernel math math.combinatorics.private ;

IN: math.combinatorics

: selections ( seq n -- selections )
dup 0 > [ (selections) ] [ 2drop { } ] if ;