Sorting algorithms/Shell sort: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
m (→{{header|Wren}}: Minor tidy) |
||
Line 3,725: | Line 3,725: | ||
=={{header|Wren}}== |
=={{header|Wren}}== |
||
Based on the Wikipedia article pseudo-code. |
Based on the Wikipedia article pseudo-code. |
||
<syntaxhighlight lang=" |
<syntaxhighlight lang="wren">var shellSort = Fn.new { |a| |
||
var n = a.count |
var n = a.count |
||
var gaps = [701, 301, 132, 57, 23, 10, 4, 1] |
var gaps = [701, 301, 132, 57, 23, 10, 4, 1] |
||
Line 3,743: | Line 3,743: | ||
} |
} |
||
var |
var array = [ [4, 65, 2, -31, 0, 99, 2, 83, 782, 1], [7, 5, 2, 6, 1, 4, 2, 6, 3] ] |
||
for (a in |
for (a in array) { |
||
System.print("Before: %(a)") |
System.print("Before: %(a)") |
||
shellSort.call(a) |
shellSort.call(a) |
||
Line 3,762: | Line 3,762: | ||
Alternatively we can just call a library method. |
Alternatively we can just call a library method. |
||
{{libheader|Wren-sort}} |
{{libheader|Wren-sort}} |
||
<syntaxhighlight lang=" |
<syntaxhighlight lang="wren">import "./sort" for Sort |
||
var |
var array = [ [4, 65, 2, -31, 0, 99, 2, 83, 782, 1], [7, 5, 2, 6, 1, 4, 2, 6, 3] ] |
||
for (a in |
for (a in array) { |
||
System.print("Before: %(a)") |
System.print("Before: %(a)") |
||
Sort.shell(a) |
Sort.shell(a) |