Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
20
Task/Combinations/Icon/combinations-1.icon
Normal file
20
Task/Combinations/Icon/combinations-1.icon
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
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
|
||||
8
Task/Combinations/Icon/combinations-2.icon
Normal file
8
Task/Combinations/Icon/combinations-2.icon
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
procedure lcomb(L,i) #: list combinations
|
||||
local j
|
||||
|
||||
if i < 1 then fail
|
||||
suspend if i = 1 then [!L]
|
||||
else [L[j := 1 to *L - i + 1]] ||| lcomb(L[j + 1:0],i - 1)
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue