Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,37 @@
|
|||
beadSort: function [items][
|
||||
a: new items
|
||||
m: neg infinity
|
||||
s: 0
|
||||
|
||||
loop a 'x [
|
||||
if x > m -> m: x
|
||||
]
|
||||
|
||||
beads: array.of: m * size a 0
|
||||
|
||||
loop 0..dec size a 'i [
|
||||
loop 0..dec a\[i] 'j ->
|
||||
beads\[j + i * m]: 1
|
||||
]
|
||||
|
||||
loop 0..dec m 'j [
|
||||
s: 0
|
||||
loop 0..dec size a 'i [
|
||||
s: s + beads\[j + i*m]
|
||||
beads\[j + i*m]: 0
|
||||
]
|
||||
|
||||
loop ((size a)-s)..dec size a 'i ->
|
||||
beads\[j + i*m]: 1
|
||||
]
|
||||
|
||||
loop 0..dec size a 'i [
|
||||
j: 0
|
||||
while [and? [j < m] [beads\[j + i*m] > 0]] -> j: j + 1
|
||||
a\[i]: j
|
||||
]
|
||||
|
||||
return a
|
||||
]
|
||||
|
||||
print beadSort [3 1 2 8 5 7 9 4 6]
|
||||
Loading…
Add table
Add a link
Reference in a new issue