Handbook
Glossary
heapsort-with ( seq quot: ( elt -- key ) -- sorted-seq )
Vocabulary
sorting
.
heap
Inputs
seq
an
object
quot
a
quotation
with stack effect
( elt -- key )
Outputs
sorted-seq
an
object
Definition
USING:
heaps
kernel
sequences
vectors
;
IN:
sorting.heap
:
heapsort-with
( seq quot: ( elt -- key ) -- sorted-seq )
[
over
length
<vector>
min-heap
boa
[
[
[
[
dup
]
]
dip
compose
]
dip
[
heap-push
]
curry
compose
each
]
keep
]
[
drop
[
length
]
keep
new-resizable
[
[
[
drop
]
]
dip
[
push
]
curry
compose
slurp-heap
]
keep
]
[
drop
like
]
2tri
;
inline