Sorting algorithms/Comb sort: Difference between revisions
Content added Content deleted
(Scala contribution added.) |
|||
Line 622: | Line 622: | ||
</pre> |
</pre> |
||
=={{header|Elena}}== |
=={{header|Elena}}== |
||
ELENA 3. |
ELENA 3.4 : |
||
<lang elena>import extensions. |
<lang elena>import extensions. |
||
import system'math. |
import system'math. |
||
import system'routines. |
import system'routines. |
||
extension |
extension op |
||
{ |
{ |
||
combSort |
combSort |
||
[ |
[ |
||
var list := self clone. |
var list := self clone. |
||
real gap := list length. |
real gap := list length. |
||
bool swaps := true. |
bool swaps := true. |
||
Line 639: | Line 639: | ||
gap /= 1.247330950103979r. |
gap /= 1.247330950103979r. |
||
if (gap<1) [ gap := 1 ]. |
if (gap<1) [ gap := 1 ]. |
||
int i := 0. |
int i := 0. |
||
swaps := false. |
swaps := false. |
||
Line 653: | Line 653: | ||
]. |
]. |
||
]. |
]. |
||
^ list |
^ list |
||
] |
] |
||
} |
} |
||
public program |
|||
[ |
[ |
||
var list := (3, 5, 1, 9, 7, 6, 8, 2, 4 ). |
var list := (3, 5, 1, 9, 7, 6, 8, 2, 4 ). |
||
console printLine("before:", list). |
console printLine("before:", list). |
||
console printLine("after :", list combSort). |
console printLine("after :", list combSort). |
||
] |
]</lang> |
||
{{out}} |
{{out}} |
||
<pre> |
<pre> |