Sorting algorithms/Cocktail sort: Difference between revisions
Content added Content deleted
(→{{header|Vlang}}: Rename "Vlang" in "V (Vlang)") |
(Added Quackery.) |
||
Line 3,519: | Line 3,519: | ||
if not swap: |
if not swap: |
||
break</syntaxhighlight> |
break</syntaxhighlight> |
||
=={{header|Quackery}}== |
|||
<syntaxhighlight lang="Quackery"> |
|||
[ 2dup 1+ peek dip peek > ] is compare ( [ n --> b ) |
|||
[ dup 1+ unrot |
|||
2dup peek |
|||
dip |
|||
[ 2dup 1+ peek |
|||
unrot poke |
|||
swap ] |
|||
unrot poke ] is exchange ( [ n --> [ ) |
|||
[ [ 0 swap |
|||
dup size 1 - times |
|||
[ dup i^ compare if |
|||
[ i^ exchange |
|||
dip 1+ ] ] |
|||
over while |
|||
dup size 1 - times |
|||
[ dup i compare if |
|||
[ i exchange |
|||
dip 1+ ] ] |
|||
over while |
|||
nip again ] |
|||
nip ] is cocktail ( [ --> [ ) |
|||
randomise |
|||
[] 20 times [ 89 random 10 + join ] |
|||
dup echo cr |
|||
cocktail echo</syntaxhighlight> |
|||
{{out}} |
|||
<pre>[ 46 42 73 92 95 19 27 52 33 12 60 70 34 45 93 15 64 41 12 55 ] |
|||
[ 12 12 15 19 27 33 34 41 42 45 46 52 55 60 64 70 73 92 93 95 ]</pre> |
|||
=={{header|R}}== |
=={{header|R}}== |