ALGORITHM 154 COMBINATION IN LEXICOGRAPHICAL ORDER

comment The distinct combinations of the first n integers taken r at a time are generated in I in lexicographical order starting with an initial combination of the r integers 1, 2, ... , r. Each call of the procedure, after the first, must have in I the previous generated combination. The Boolean variable first is nonlocal to COMB1 and must be true before the first call.