The code here is written in Octave, which is a free software alternative to Matlab. It may work with this last language too. Each file below defines a single function. In order to use that function from Octave's command line, the file must be in the path of searched directories.
y = next_base (x, n) - Number in base n after x Return the number written in base n that is after x. INPUT: x : vector representing a number written in base n. 1x(1) is the 1st digit, x(2) the second etc. n : base. OUTPUT: y : vector representing the number x+1 in base n. Example: next_base(6,7) == [1 0];
y = next_set (x, n) - Subset of {1..n} after x Return the subset of {1..n} after x, when subsets are ordered first by size, then by lexicographical order. INPUT: x : vector or matrix representing a subset of {1..n}. n : n upper bound for elements of x. OUTPUT: y : vector or matrix representing the subset after x for the lexicographical order. Examples: next_set([],10) == 1; next_set(1:3,10) == [1,2,4]; next_set(8:10,10) == 1:4.