Sorting algorithms/Shell sort: Difference between revisions

Content deleted Content added
Undo revision 63693 by Bathala (Talk)
Add new section for Lisaac
Line 340:
}
}</lang>
 
=={{header|Lisaac}}==
<lang Lisaac>
Section Header
 
+ name := SHELL_SORT;
 
- external := `#include <time.h>`;
 
Section Public
 
- main <- (
+ a : ARRAY[INTEGER];
 
a := ARRAY[INTEGER].create 0 to 100;
`srand(time(NULL))`;
0.to 100 do { i : INTEGER;
a.put `rand()`:INTEGER to i;
};
 
shell a;
 
a.foreach { item : INTEGER;
item.print;
'\n'.print;
};
);
 
- shell a : ARRAY[INTEGER] <- (
+ lower, length, increment, temp : INTEGER;
 
lower := a.lower;
length := a.upper - lower + 1;
increment := length;
{
increment := increment / 2;
increment > 0
}.while_do {
increment.to (length - 1) do { i : INTEGER; + j : INTEGER;
temp := a.item(lower + i);
j := i - increment;
{ (j >= 0) && { a.item(lower + j) > temp } }.while_do {
a.put (a.item(lower + j)) to (lower + j + increment);
j := j - increment;
};
a.put temp to (lower + j + increment);
};
};
);
</lang>
 
=={{header|OCaml}}==