Sorting algorithms/Patience sort: Difference between revisions
Content deleted Content added
Added Quackery. |
|||
Line 2,017:
{{out}}
<pre>[-31, 0, 1, 2, 4, 65, 83, 99, 782]</pre>
=={{header|Quackery}}==
uses <code>bsearchwith</code> from [[Binary search#Quackery]] and <code>merge</code> from [[Merge sort#Quackery]].
<lang Quackery> [ dip [ 0 over size rot ]
nested bsearchwith
[ -1 peek
dip [ -1 peek ] > ]
drop ] is searchpiles ( [ n --> n )
[ dup size dup 1 = iff
[ drop 0 peek ] done
2 / split
recurse swap recurse
merge ] is k-merge ( [ --> [ )
[ 1 split dip nested
witheach
[ 2dup dip dup
searchpiles
over size over = iff
[ 2drop
nested nested join ]
else
[ dup dip
[ peek swap join
swap ]
poke ] ]
k-merge ] is patience-sort ( [ --> [ )
' [ 0 1 2 3 4 5 6 7 8 9 ]
shuffle dup echo cr
patience-sort echo</lang>
{{out}}
<pre>[ 6 9 2 3 1 7 8 4 0 5 ]
[ 0 1 2 3 4 5 6 7 8 9 ]</pre>
=={{header|Racket}}==
|