September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,33 +1,33 @@
|
|||
import extensions.
|
||||
import system'routines.
|
||||
import extensions;
|
||||
import system'routines;
|
||||
|
||||
extension $op
|
||||
extension op
|
||||
{
|
||||
selectionSort
|
||||
[
|
||||
var copy := self clone.
|
||||
selectionSort()
|
||||
{
|
||||
var copy := self.clone();
|
||||
|
||||
0 till(copy length) do(:i)
|
||||
[
|
||||
int k := i.
|
||||
(i + 1) till(copy length) do(:j)
|
||||
[
|
||||
for(int i := 0, i < copy.Length, i += 1)
|
||||
{
|
||||
int k := i;
|
||||
for(int j := i + 1, j < copy.Length, j += 1)
|
||||
{
|
||||
if (copy[j] < copy[k])
|
||||
[
|
||||
k := j.
|
||||
]
|
||||
].
|
||||
copy exchange(i,k).
|
||||
].
|
||||
{
|
||||
k := j
|
||||
}
|
||||
};
|
||||
copy.exchange(i,k)
|
||||
};
|
||||
|
||||
^ copy
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
program =
|
||||
[
|
||||
var list := ("this", "is", "a", "test", "of", "generic", "selection", "sort").
|
||||
public program()
|
||||
{
|
||||
var list := new string[]{"this", "is", "a", "test", "of", "generic", "selection", "sort"};
|
||||
|
||||
console printLine("before:",list).
|
||||
console printLine("after:",list selectionSort).
|
||||
].
|
||||
console.printLine("before:",list.asEnumerable());
|
||||
console.printLine("after:",list.selectionSort().asEnumerable())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue