September Morn Update

This commit is contained in:
Ingy döt Net 2019-09-12 10:33:56 -07:00
parent 4e2d22a71d
commit aac6731f2c
6856 changed files with 141342 additions and 21127 deletions

View file

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