Sorting algorithms/Gnome sort: Difference between revisions
added RPL
m (→{{header|Wren}}: Minor tidy) |
(added RPL) |
||
Line 4,089:
j = j + 1 ok ok end
</syntaxhighlight>
=={{header|RPL}}==
{{works with|RPL|HP-49C}}
« DUP SIZE 1 → s h
« 2
'''WHILE''' h s < '''REPEAT'''
'''IF''' OVER h GETI UNROT GET ≤ '''THEN'''
'h' ▶ 1 +
'''ELSE'''
SWAP h DUP2 DUP 1 + SUB REVLIST REPL SWAP
'''IF''' 'h' DECR NOT '''THEN''' 'h' ▶ 1 + '''END'''
'''END'''
'''END''' DROP
» » '<span style="color:blue">GNOMESORT</span>' STO
{ 7 6 5 9 8 4 3 1 2 0 } <span style="color:blue">GNOMESORT</span>
{{out}}
<pre>
1: { 0 1 2 3 4 5 6 7 8 9 }
</pre>
This implementation of gnome sort is 33 times slower than the <code>SORT</code> built-in function on a HP-50g.
=={{header|Ruby}}==
|