Handbook
Glossary
(bubble-sort-with!) ( seq quot: ( obj1 obj2 -- <=> ) -- )
Vocabulary
sorting
.
bubble
.
private
Inputs
seq
an
object
quot
a
quotation
with stack effect
( obj1 obj2 -- <=> )
Outputs
None
Definition
USING:
kernel
math
math.order
ranges
sequences
sequences.private
;
IN:
sorting.bubble.private
::
(bubble-sort-with!)
( seq quot: ( obj1 obj2 -- <=> ) -- )
seq
length
1
-
[
f
over
[0..b)
[|
i |
i i 1
+
[
seq
nth-unsafe
]
bi@
2dup
quot
call
+gt+
=
[
i 1
+
i
[
seq
set-nth-unsafe
]
bi-curry@
bi*
2drop
i
t
]
[
2drop
]
if
]
each
]
loop
drop
;
inline