Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,20 @@
|
|||
def merge(var xs :List, var ys :List) {
|
||||
var result := []
|
||||
while (xs =~ [x] + xr && ys =~ [y] + yr) {
|
||||
if (x <= y) {
|
||||
result with= x
|
||||
xs := xr
|
||||
} else {
|
||||
result with= y
|
||||
ys := yr
|
||||
}
|
||||
}
|
||||
return result + xs + ys
|
||||
}
|
||||
|
||||
def sort(list :List) {
|
||||
if (list.size() <= 1) { return list }
|
||||
def split := list.size() // 2
|
||||
return merge(sort(list.run(0, split)),
|
||||
sort(list.run(split)))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue