COMBIGEN
Name
COMBIGEN
Purpose
Generates all possible combinations n-choose-k.
Category
Math
Calling Sequence
Result = COMBIGEN(N, K)
Inputs
N: Maximum number.
K: Number of elements in each combination.
Outputs
Returns a M x K array of all K-length combinations of numbers from 0 to N-1.
Example
Generate all combinations 5-choose-3:
IDL> print, combigen(5,3)
0 0 0 0 0 0 1 1 1 2
1 1 1 2 2 3 2 2 3 3
2 3 4 3 4 4 3 4 4 4
Modification History
Written by Jeremy Bailin
1 April 2011 Initial writing.