/* IO(1) */

/*
matrix C( int m, int n)
{
*/
/* generate combinatorial matrix of m indices taken n at a time, m >= n */
/*
  matrix c;
  vector v;
  int i, j, k, R;

  if( narg != 2 || m < 1 || n < 1 || m < n) {
    print( "C: bad arguments");
    return 0;
  }
*/
  R = prod(n+1:m) / prod(1:m-n); /* number of combinations == rows(c) */

  c = zeros( R, n);

  print( R);

  i = 1; j = 1; k = n;

  while( i < m) {

    v = [i:n+i-1];
    c(i) = v;

    while( j 
  while( i < R) {

    v = [j:n+j-1];

    c(++i) = v;

    while( k > 1) {

      while( v(n) < m) {
        ++v(n);
        c(++i) = v;
      }

      v(n) = v(n-1) + 1;
      --k;
      ++v(k:n);
    }
    ++j;
  }
/*
  return c;
}
*/
