@Beachtante: Acutally you should know the syntax in the bubbles function itself. Only in the program part I use exotic syntax.
"Improved" code to help a bit. Removed modern syntax:
program champagnesort;
{$mode objfpc}
function BubblesSort(var a: array of integer ):boolean;
var
i:integer;
begin
repeat
Result := true;
for i := Succ(low(a)) to High(a) do
begin
if a[ Pred(i) ] > a[ i ] then // xor swap
begin
a[Pred(i)] := a[Pred(i)] xor a[i];
a[i] := a[Pred(i)] xor a[i];
a[Pred(i)] := a[Pred(i)] xor a[i];
Result := i = 0;
end;
end ;
until Result;
end;
const
a:array[0..7] of integer = (123123,12,1,55,6686,5,1555,666);
var
i:integer;
begin
BubblesSort(a);
for i := 0 to 7 do writeln(a[i]);
end.
In some dialects of "classic" pascal this will give you an eleven... Teachers usually are not able to write such code...
But I still recommend to write it like this if it is not homework (and you use trunk!):
program champagnesort;
{$mode objfpc}
function BubblesSort(var a: array of integer ):boolean;
var
i:integer;
begin
repeat
Result := true;
for i := Succ(low(a)) to High(a) do
begin
if a[ Pred(i) ] > a[ i ] then // xor swap
begin
a[Pred(i)] := a[Pred(i)] xor a[i];
a[i] := a[Pred(i)] xor a[i];
a[Pred(i)] := a[Pred(i)] xor a[i];
Result := i = 0;
end;
end ;
until Result;
end;
var
a:array of integer;
v:integer;
begin
a := [123123,12,1,55,6686,5,1555,666]; // modern dynamic array initialization
BubblesSort(a);
for v in a do writeln(v); // modern looping over values without using an index
end.
You can even improve it further...(which I saw but this is enough).