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,40 +1,41 @@
import extensions.
import system'routines.
import extensions;
import system'routines;
extension $op
extension op
{
gnomeSort
[
var list := self clone.
int i := 1.
int j := 2.
gnomeSort()
{
var list := self.clone();
int i := 1;
int j := 2;
while (i < list length)
[
while (i < list.Length)
{
if (list[i-1]<=list[i])
[
i := j.
{
i := j;
j += 1
];
[
list exchange(i-1,i).
i -= 1.
}
else
{
list.exchange(i-1,i);
i -= 1;
if (i==0)
[
i := 1.
{
i := 1;
j := 2
]
]
].
}
}
};
^ list
]
}
}
program =
[
var list := (3, 9, 4, 6, 8, 1, 7, 2, 5).
public program()
{
var list := new int[]{3, 9, 4, 6, 8, 1, 7, 2, 5};
console printLine("before:", list).
console printLine("after :", list gnomeSort).
].
console.printLine("before:", list.asEnumerable());
console.printLine("after :", list.gnomeSort().asEnumerable())
}