Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
var insertionSort = Fn.new { |a|
|
||||
for (i in 1..a.count-1) {
|
||||
var v = a[i]
|
||||
var j = i - 1
|
||||
while (j >= 0 && a[j] > v) {
|
||||
a[j+1] = a[j]
|
||||
j = j - 1
|
||||
}
|
||||
a[j+1] = v
|
||||
}
|
||||
}
|
||||
|
||||
var as = [ [4, 65, 2, -31, 0, 99, 2, 83, 782, 1], [7, 5, 2, 6, 1, 4, 2, 6, 3] ]
|
||||
for (a in as) {
|
||||
System.print("Before: %(a)")
|
||||
insertionSort.call(a)
|
||||
System.print("After : %(a)")
|
||||
System.print()
|
||||
}
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
import "/sort" for Sort
|
||||
|
||||
var as = [ [4, 65, 2, -31, 0, 99, 2, 83, 782, 1], [7, 5, 2, 6, 1, 4, 2, 6, 3] ]
|
||||
for (a in as) {
|
||||
System.print("Before: %(a)")
|
||||
Sort.insertion(a)
|
||||
System.print("After : %(a)")
|
||||
System.print()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue