21 lines
516 B
Plaintext
21 lines
516 B
Plaintext
procedure main()
|
|
return combinations(3,5,0)
|
|
end
|
|
|
|
procedure combinations(m,n,z) # demonstrate combinations
|
|
/z := 1
|
|
|
|
write(m," combinations of ",n," integers starting from ",z)
|
|
every put(L := [], z to n - 1 + z by 1) # generate list of n items from z
|
|
write("Intial list\n",list2string(L))
|
|
write("Combinations:")
|
|
every write(list2string(lcomb(L,m)))
|
|
end
|
|
|
|
procedure list2string(L) # helper function
|
|
every (s := "[") ||:= " " || (!L|"]")
|
|
return s
|
|
end
|
|
|
|
link lists
|