You can find an implementation in [Octave][1]. The function is, as in Matlab, called `nchoosek`. Documentation is [here][2]. 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.


  [1]: http://www.gnu.org/software/octave/
  [2]: http://octave.sourceforge.net/octave/function/nchoosek.html