Sorting algorithms/Shell sort: Difference between revisions
Added Easylang
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
(Added Easylang) |
||
(One intermediate revision by one other user not shown) | |||
Line 1,764:
}
}</syntaxhighlight>
=={{header|EasyLang}}==
{{trans|Lua}}
<syntaxhighlight>
proc shellsort . a[] .
inc = len a[] div 2
while inc > 0
for i = inc to len a[]
tmp = a[i]
j = i
while j > inc and a[j - inc] > tmp
a[j] = a[j - inc]
j = j - inc
.
a[j] = tmp
.
inc = floor (0.5 + inc / 2.2)
.
.
a[] = [ -12 3 0 4 7 4 8 -5 9 ]
shellsort a[]
print a[]
</syntaxhighlight>
{{out}}
<pre>
[ -12 -5 0 3 4 4 7 8 9 ]
</pre>
=={{header|Eiffel}}==
Line 3,725 ⟶ 3,752:
=={{header|Wren}}==
Based on the Wikipedia article pseudo-code.
<syntaxhighlight lang="
var n = a.count
var gaps = [701, 301, 132, 57, 23, 10, 4, 1]
Line 3,743 ⟶ 3,770:
}
var
for (a in
System.print("Before: %(a)")
shellSort.call(a)
Line 3,762 ⟶ 3,789:
Alternatively we can just call a library method.
{{libheader|Wren-sort}}
<syntaxhighlight lang="
var
for (a in
System.print("Before: %(a)")
Sort.shell(a)
|