Data update

This commit is contained in:
Ingy döt Net 2025-02-27 18:35:13 -05:00
parent 8e4e15fa56
commit 72eb4943cb
1853 changed files with 35514 additions and 9441 deletions

View file

@ -1,41 +1,32 @@
Module Checkit {
Global a$
Document a$
Module Combinations (m as long, n as long){
Function Combinations (m as long, n as long){
Global a$
Document a$
Module Level (n, s, h) {
If n=1 then {
while Len(s) {
Print h, car(s)
ToClipBoard()
If n=1 then
while Len(s)
a$<=h#str$("-")+"-"+car(s)#str$()+{
}
s=cdr(s)
}
} Else {
While len(s) {
End While
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
End While
End if
}
If m<1 or n<1 then Error
s=(,)
for i=0 to n-1 {
s=cons(s, (i,))
}
for i=0 to n-1
Append s, (i,)
next
s=s#sort()
Head=(,)
Call Level m, s, Head
=a$
}
Clear a$
Combinations 3, 5
ClipBoard a$
ClipBoard Combinations( 3, 5)
report clipboard$
}
Checkit

View file

@ -1,45 +1,55 @@
Module StepByStep {
Function CombinationsStep (a, nn) {
c1=lambda (&f, &a) ->{
=car(a) : a=cdr(a) : f=len(a)=0
}
m=len(a)
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
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--
p++
m--
End While
=lambda c, a (&f) -> {
=c(&f, &a)
}
=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)
}
}
enum out {screen="", file="out.txt"}
m=each(out)
while m
open eval(m) for output as #f
k=false
StepA=CombinationsStep((1, 2, 3, 4,5), 3)
While not k
Print #f, StepA(&k)#str$()
End While
Print #f
k=false
StepA=CombinationsStep((0, 1, 2, 3, 4), 3)
While not k
Print #f, StepA(&k)#str$()
End While
Print #f
k=false
StepA=CombinationsStep(("A", "B", "C", "D","E"), 3)
While not k
Print #f, StepA(&k)#str$("-")
End While
Print #f
k=false
StepA=CombinationsStep(("CAT", "DOG", "BAT"), 2)
While not k
Print #f, StepA(&k)#str$("-")
End While
close #f
end while
win "notepad", dir$+file
}
StepByStep

View file

@ -1,48 +1,21 @@
[ 0 swap
[ dup 0 != while
dup 1 & if
[ dip 1+ ]
1 >> again ]
drop ] is bits ( n --> n )
[ [] unrot
bit times
[ i bits
over = if
[ dip
[ i join ] ] ]
drop ] is combnums ( n n --> [ )
[ [] 0 rot
[ dup 0 != while
dup 1 & if
[ dip
[ dup dip join ] ]
dip 1+
1 >>
again ]
2drop ] is makecomb ( n --> [ )
[ over 0 = iff
[ 2drop [] ] done
combnums
[] swap witheach
[ makecomb
nested join ] ] is comb ( n n --> [ )
[ 2drop ' [ [ ] ] ]
done
dup [] = iff nip done
1 split rot tuck
1 - over recurse
dip [ rot [] ]
witheach
[ dip over join
nested join ]
nip unrot recurse join ] is comb ( n [ --> [ )
[ behead swap witheach max ] is largest ( [ --> n )
[ [] swap times
[ i^ join ]
comb
witheach
[ witheach
[ echo sp ]
cr ] ] is task ( n n --> )
[ 0 rot witheach
[ [ dip [ over * ] ] + ]
nip ] is comborder ( [ n --> n )
[ dup [] != while
sortwith
[ 2dup join
largest 1+ dup dip
[ comborder swap ]
comborder < ] ] is sortcombs ( [ --> [ )
3 5 comb
sortcombs
witheach [ witheach [ echo sp ] cr ]
3 5 task

View file

@ -1,31 +1,48 @@
[ stack ] is comb.stack
[ stack ] is comb.items
[ stack ] is comb.required
[ stack ] is comb.result
[ 0 swap
[ dup 0 != while
dup 1 & if
[ dip 1+ ]
1 >> again ]
drop ] is bits ( n --> n )
[ 1 - comb.items put
1+ comb.required put
0 comb.stack put
[] comb.result put
[ comb.required share
comb.stack size = if
[ comb.result take
comb.stack behead
drop nested join
comb.result put ]
comb.stack take
dup comb.items share
= iff
[ drop
comb.stack size 1 > iff
[ 1 comb.stack tally ] ]
else
[ dup comb.stack put
1+ comb.stack put ]
comb.stack size 1 = until ]
comb.items release
comb.required release
comb.result take ] is comb ( n n --> )
[ [] unrot
bit times
[ i bits
over = if
[ dip
[ i join ] ] ]
drop ] is combnums ( n n --> [ )
[ [] 0 rot
[ dup 0 != while
dup 1 & if
[ dip
[ dup dip join ] ]
dip 1+
1 >>
again ]
2drop ] is makecomb ( n --> [ )
[ over 0 = iff
[ 2drop [] ] done
combnums
[] swap witheach
[ makecomb
nested join ] ] is comb ( n n --> [ )
[ behead swap witheach max ] is largest ( [ --> n )
[ 0 rot witheach
[ [ dip [ over * ] ] + ]
nip ] is comborder ( [ n --> n )
[ dup [] != while
sortwith
[ 2dup join
largest 1+ dup dip
[ comborder swap ]
comborder < ] ] is sortcombs ( [ --> [ )
3 5 comb
sortcombs
witheach [ witheach [ echo sp ] cr ]

View file

@ -1,16 +1,31 @@
[ dup size dip
[ witheach
[ over swap peek swap ] ]
nip pack ] is arrange ( [ [ --> [ )
[ stack ] is comb.stack
[ stack ] is comb.items
[ stack ] is comb.required
[ stack ] is comb.result
[ 1 - comb.items put
1+ comb.required put
0 comb.stack put
[] comb.result put
[ comb.required share
comb.stack size = if
[ comb.result take
comb.stack behead
drop nested join
comb.result put ]
comb.stack take
dup comb.items share
= iff
[ drop
comb.stack size 1 > iff
[ 1 comb.stack tally ] ]
else
[ dup comb.stack put
1+ comb.stack put ]
comb.stack size 1 = until ]
comb.items release
comb.required release
comb.result take ] is comb ( n n --> )
' [ 10 20 30 40 50 ]
3 5 comb
witheach
[ dip dup arrange
witheach [ echo sp ]
cr ]
drop
cr
$ "zero one two three four" nest$
' [ 4 3 1 0 1 4 3 ] arrange
witheach [ echo$ sp ]
witheach [ witheach [ echo sp ] cr ]

View file

@ -0,0 +1,16 @@
[ dup size dip
[ witheach
[ over swap peek swap ] ]
nip pack ] is arrange ( [ [ --> [ )
' [ 10 20 30 40 50 ]
3 5 comb
witheach
[ dip dup arrange
witheach [ echo sp ]
cr ]
drop
cr
$ "zero one two three four" nest$
' [ 4 3 1 0 1 4 3 ] arrange
witheach [ echo$ sp ]