Generating binomial combinations

Is there a reasonably simple way to generate in Igor Pro a list of all distinct (unordered) combinations of 'm' sequential integers taken 'k' at a time? The number of combinations is the well-known binomial coefficient (m k)^T , that I abbreviate here as Cmk, but I want a list of the combinations themselves. For example, the list of 4 integers taken 3 at a time would be {0,1,2}, {1,2,3}, {2, 3, 0}, {3,0,1}. The ordering of numbers within each triplet, or of the triplets themselves does not matter. In general, a 2D wave with /N=(Cmk,k) should be the result.

I believe that my goal is similar to the MATLAB command:
`C = nchoosek(v,k) returns a matrix containing all possible combinations of the elements of vector v taken k at a time. Matrix C has k columns and n!/((n–k)! k!) rows, where n is length(v).`
In IP7 you can do this with:
Make/O/N=4 data
data = p
StatsSample/N=3/ACMB data

It is the /ACMB that is new to IP7. Results are in a 2D wave called M_Combinations.
Thanks, Stephen. I'll keep this in mind when I finally install the released IP7. Putting the method in `StatsSample` seems somewhat misleading, since the required analysis is combinatorial rather than random statistical.

I have come up with a simple nested for-loop function in IP6 that meets my immediate needs in generating the binomial combinations.
s.r.chinn wrote:
Thanks, Stephen. I'll keep this in mind when I finally install the released IP7. Putting the method in `StatsSample` seems somewhat misleading, since the required analysis is combinatorial rather than random statistica

FWIW:
1. this option was added in StatsSample because it was used for resampling all possible combinations.
2. if you have a sufficiently recent version of IP6 this option would be available.

A.G.