June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,33 @@
|
|||
import extensions.
|
||||
|
||||
extension $op
|
||||
{
|
||||
insertionSort
|
||||
= self clone; insertionSort(0, self length - 1).
|
||||
|
||||
insertionSort(IntNumber first, IntNumber last)
|
||||
[
|
||||
(first + 1) to:last do(:i)
|
||||
[
|
||||
var entry := self[i].
|
||||
int j := i.
|
||||
|
||||
while ((j > first)&& $(self[j - 1] > entry))
|
||||
[
|
||||
self[j] := self[j - 1].
|
||||
|
||||
j -= 1
|
||||
].
|
||||
|
||||
self[j] := entry
|
||||
]
|
||||
]
|
||||
}
|
||||
|
||||
program =
|
||||
[
|
||||
var list := (3, 9, 4, 6, 8, 1, 7, 2, 5).
|
||||
|
||||
console printLine("before:", list).
|
||||
console printLine("after :", list insertionSort).
|
||||
].
|
||||
Loading…
Add table
Add a link
Reference in a new issue