I try to convert following algorithm to java code, but have trouble with the object reference. Thanks very much if any of you can help me.
proc generate([c], m, k, list) if (m > M) then list.insert([c]) else for i :=1 to min(k+1, K) generate([c].prepend(i), m+1, max(i, k), list) endfor endif endproc
proc main list(); generate([1], 1, 1, list) endproc
where c is a vector.
The output of the programe, for example for K = 2, M=4, will be: 1111 2111 1211 2211 1121 1212 1221 2221