12 lines
276 B
Text
12 lines
276 B
Text
go =>
|
|
% Integers 1..K
|
|
N = 3,
|
|
K = 5,
|
|
printf("comb1(3,5): %w\n", comb1(N,K)),
|
|
nl.
|
|
|
|
% Recursive (numbers)
|
|
comb1(M,N) = comb1_(M, 1..N).
|
|
comb1_(0, _X) = [[]].
|
|
comb1_(_M, []) = [].
|
|
comb1_(M, [X|Xs]) = [ [X] ++ Xs2 : Xs2 in comb1_(M-1, Xs) ] ++ comb1_(M, Xs).
|