June 2018 Update

This commit is contained in:
Ingy döt Net 2018-06-22 20:57:24 +00:00
parent ba8067c3b7
commit 22f33d4004
5278 changed files with 84726 additions and 14379 deletions

View file

@ -0,0 +1,50 @@
import extensions.
import system'math.
import system'routines.
extension $op
{
cocktailSort
[
var list := self clone.
bool swapped := true.
while(swapped)
[
swapped := false.
0 to(list length - 2) do(:i)
[
if (list[i]>list[i+1])
[
list exchange(i,i+1).
swapped := true.
]
].
ifnot (swapped)
[
^ list
].
swapped := false.
(list length - 2) to(0) do(:i)
[
if (list[i]>list[i+1])
[
list exchange(i,i+1).
swapped := true.
]
].
].
^ list
]
}
program =
[
var list := (3, 5, 1, 9, 7, 6, 8, 2, 4 ).
console printLine("before:", list).
console printLine("after :", list cocktailSort).
].