You can find an implementation in Octave. The function is, as in Matlab, called nchoosek
. Documentation is here. For the theory behind this type of algorithms, you can consult section 7.2.1 of Volume 4A of The Art Of Computer Programming by Donald Knuth.