June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -0,0 +1,40 @@
|
|||
import extensions.
|
||||
import system'routines.
|
||||
|
||||
extension $op
|
||||
{
|
||||
gnomeSort
|
||||
[
|
||||
var list := self clone.
|
||||
int i := 1.
|
||||
int j := 2.
|
||||
|
||||
while (i < list length)
|
||||
[
|
||||
if (list[i-1]<=list[i])
|
||||
[
|
||||
i := j.
|
||||
j += 1
|
||||
];
|
||||
[
|
||||
list exchange(i-1,i).
|
||||
i -= 1.
|
||||
if (i==0)
|
||||
[
|
||||
i := 1.
|
||||
j := 2
|
||||
]
|
||||
]
|
||||
].
|
||||
|
||||
^ list
|
||||
]
|
||||
}
|
||||
|
||||
program =
|
||||
[
|
||||
var list := (3, 9, 4, 6, 8, 1, 7, 2, 5).
|
||||
|
||||
console printLine("before:", list).
|
||||
console printLine("after :", list gnomeSort).
|
||||
].
|
||||
Loading…
Add table
Add a link
Reference in a new issue