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,41 @@
Module Checkit {
Global a$
Document a$
Module Combinations (m as long, n as long){
Module Level (n, s, h) {
If n=1 then {
while Len(s) {
Print h, car(s)
ToClipBoard()
s=cdr(s)
}
} Else {
While len(s) {
call Level n-1, cdr(s), cons(h, car(s))
s=cdr(s)
}
}
Sub ToClipBoard()
local m=each(h)
Local b$=""
While m {
b$+=If$(Len(b$)<>0->" ","")+Format$("{0::-10}",Array(m))
}
b$+=If$(Len(b$)<>0->" ","")+Format$("{0::-10}",Array(s,0))+{
}
a$<=b$ ' assign to global need <=
End Sub
}
If m<1 or n<1 then Error
s=(,)
for i=0 to n-1 {
s=cons(s, (i,))
}
Head=(,)
Call Level m, s, Head
}
Clear a$
Combinations 3, 5
ClipBoard a$
}
Checkit

View file

@ -0,0 +1,45 @@
Module StepByStep {
Function CombinationsStep (a, nn) {
c1=lambda (&f, &a) ->{
=car(a) : a=cdr(a) : f=len(a)=0
}
m=len(a)
c=c1
n=m-nn+1
p=2
while m>n {
c1=lambda c2=c,n=p, z=(,) (&f, &m) ->{
if len(z)=0 then z=cdr(m)
=cons(car(m),c2(&f, &z))
if f then z=(,) : m=cdr(m) : f=len(m)+len(z)<n
}
c=c1
p++
m--
}
=lambda c, a (&f) -> {
=c(&f, &a)
}
}
k=false
StepA=CombinationsStep((1, 2, 3, 4,5), 3)
while not k {
Print StepA(&k)
}
k=false
StepA=CombinationsStep((0, 1, 2, 3, 4), 3)
while not k {
Print StepA(&k)
}
k=false
StepA=CombinationsStep(("A", "B", "C", "D","E"), 3)
while not k {
Print StepA(&k)
}
k=false
StepA=CombinationsStep(("CAT", "DOG", "BAT"), 2)
while not k {
Print StepA(&k)
}
}
StepByStep