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,44 @@
Module Checkit {
Global a$
Document a$
Module Permutations (s){
Module Level (n, s, h) {
If n=1 then {
while Len(s) {
m1=each(h)
while m1 {
Print Array$(m1);" ";
}
Print Array$(S)
ToClipBoard()
s=cdr(s)
}
} Else {
for i=1 to len(s) {
call Level n-1, cdr(s), cons(h, car(s))
s=cons(cdr(s), car(s))
}
}
Sub ToClipBoard()
local m=each(h)
Local b$=""
While m {
b$+=If$(Len(b$)<>0->" ","")+Array$(m)+" "
}
b$+=If$(Len(b$)<>0->" ","")+Array$(s,0)+" "+{
}
a$<=b$ ' assign to global need <=
End Sub
}
If len(s)=0 then Error
Head=(,)
Call Level Len(s), s, Head
}
Clear a$
Permutations (1,2,3,4)
Permutations (100, 200, 500)
Permutations ("A", "B", "C","D")
Permutations ("DOG", "CAT", "BAT")
ClipBoard a$
}
Checkit

View file

@ -0,0 +1,43 @@
Module StepByStep {
Function PermutationStep (a) {
c1=lambda (&f, a) ->{
=car(a)
f=true
}
m=len(a)
c=c1
while m>1 {
c1=lambda c2=c,p, m=(,) (&f, a) ->{
if len(m)=0 then m=a
=cons(car(m),c2(&f, cdr(m)))
if f then f=false:p++: m=cons(cdr(m), car(m)) : if p=len(m) then p=0 : m=(,):: f=true
}
c=c1
m--
}
=lambda c, a (&f) -> {
=c(&f, a)
}
}
k=false
StepA=PermutationStep((1,2,3,4))
while not k {
Print StepA(&k)
}
k=false
StepA=PermutationStep((100,200,300))
while not k {
Print StepA(&k)
}
k=false
StepA=PermutationStep(("A", "B", "C", "D"))
while not k {
Print StepA(&k)
}
k=false
StepA=PermutationStep(("DOG", "CAT", "BAT"))
while not k {
Print StepA(&k)
}
}
StepByStep