Your solution is to use the pipeline function of the table to return your combinations.
Your function can live in its own package (with the state of the package), which returns the data you need in the order you want. A state is a set of variables determined by the number of returned columns, initialized with initial initial values ββ(A = 1, B = A + 1, C = B + 1, D = C + 1, etc.). Then you just
PIPE ROW(a,b,c,d); -- increment D -- if D overflow limit, increment C and re-init D to C+1 -- if C overflow limit-1, increment B and re-init C to B+1 -- if B overflow limit-2, increment A and re-init B to A+1 -- if A overflow limit-3, the end
This outputs for N = 6
1,2,3,4 1,2,3,5 1,2,3,6 1,2,4,5 1,2,4,6 1,3,4,5 1,3,4,6 2,3,4,5 2,3,4,6 2,3,5,6 3,4,5,6