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,42 @@
import extensions.
import system'math.
import system'routines.
extension $op
{
combSort
[
var list := self clone.
real gap := list length.
bool swaps := true.
while ((gap > 1)|| (swaps))
[
gap /= 1.247330950103979r.
if (gap<1) [ gap := 1 ].
int i := 0.
swaps := false.
while (i + gap roundedInt < list length)
[
int igap := i + gap roundedInt.
if (list[i] > list[igap])
[
list exchange(i,igap).
swaps := true
].
i += 1
].
].
^ list
]
}
program =
[
var list := (3, 5, 1, 9, 7, 6, 8, 2, 4 ).
console printLine("before:", list).
console printLine("after :", list combSort).
].