Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View 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

View 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