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,25 @@
native scala.collection.mutable.Queue
val hamming =
q2 = Queue()
q3 = Queue()
q5 = Queue()
def enqueue( n ) =
q2.enqueue( n*2 )
q3.enqueue( n*3 )
q5.enqueue( n*5 )
def stream =
val n = min( min(q2.head(), q3.head()), q5.head() )
if q2.head() == n then q2.dequeue()
if q3.head() == n then q3.dequeue()
if q5.head() == n then q5.dequeue()
enqueue( n )
n # stream()
for q <- [q2, q3, q5] do q.enqueue( 1 )
stream()

View file

@ -0,0 +1,11 @@
val hamming = 1 # merge( map((2*), hamming), merge(map((3*), hamming), map((5*), hamming)) )
def
merge( inx@x:_, iny@y:_ )
| x < y = x # merge( inx.tail(), iny )
| x > y = y # merge( inx, iny.tail() )
| otherwise = merge( inx, iny.tail() )
println( hamming.take(20) )
println( hamming(1690) )
println( hamming(2000) )