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,21 @@
class SORT{T < $IS_LT{T}} is
private swap(inout a, inout b:T) is
temp ::= a;
a := b;
b := temp;
end;
bubble_sort(inout a:ARRAY{T}) is
i:INT;
if a.size < 2 then return; end;
loop
sorted ::= true;
loop i := 0.upto!(a.size - 2);
if a[i+1] < a[i] then
swap(inout a[i+1], inout a[i]);
sorted := false;
end;
end;
until!(sorted);
end;
end;
end;

View file

@ -0,0 +1,7 @@
class MAIN is
main is
a:ARRAY{INT} := |10, 9, 8, 7, 6, -10, 5, 4|;
SORT{INT}::bubble_sort(inout a);
#OUT + a + "\n";
end;
end;