RosettaCodeData/Task/Combinations/Pop11/combinations.pop11

18 lines
382 B
Text
Raw Permalink Normal View History

2013-04-10 22:43:41 -07:00
define comb(n, m);
lvars ress = [];
define do_combs(l, m, el_lst);
lvars i;
if m = 0 then
cons(rev(el_lst), ress) -> ress;
else
for i from l to n - m do
do_combs(i + 1, m - 1, cons(i, el_lst));
endfor;
endif;
enddefine;
do_combs(0, m, []);
rev(ress);
enddefine;
comb(5, 3) ==>