all tasks

This commit is contained in:
Ingy döt Net 2013-04-11 01:07:29 -07:00
parent b83f433714
commit 68f8f3e56b
14735 changed files with 178959 additions and 0 deletions

View file

@ -0,0 +1,42 @@
bundle Default {
class Cocktail {
function : Main(args : String[]) ~ Nil {
values := [5, -1, 101, -4, 0, 1, 8, 6, 2, 3 ];
CocktailSort(values);
each(i : values) {
values[i]->PrintLine();
};
}
function : CocktailSort(a : Int[]) ~ Nil {
swapped : Bool;
do {
swapped := false;
continue := true;
for (i := 0; i <= a->Size() - 2 & continue; i += 1;) {
if(a[i] > a[i + 1]) {
temp := a[i];
a[i] := a[i+1];
a[i+1] := temp;
swapped := true;
};
};
if(swapped <> true) {
continue := false;
};
swapped := false;
for(i := a->Size() - 2; i >= 0; i -= 1;){
if(a[i] > a[i + 1]) {
temp := a[i];
a[i] := a[i+1];
a[i + 1] := temp;
swapped := true;
};
};
}
while(swapped);
}
}
}