sorting.bubble: loop up to last changed index.
parent
0d3fc9d976
commit
d21ce7aa1c
|
@ -9,10 +9,10 @@ IN: sorting.bubble
|
||||||
<PRIVATE
|
<PRIVATE
|
||||||
|
|
||||||
:: (bubble-sort!) ( seq quot: ( obj1 obj2 -- <=> ) -- )
|
:: (bubble-sort!) ( seq quot: ( obj1 obj2 -- <=> ) -- )
|
||||||
seq length [
|
seq length 1 - [
|
||||||
1 - f over [0,b) [| i |
|
f over [0,b) [| i |
|
||||||
i i 1 + [ seq nth-unsafe ] bi@ 2dup quot call +gt+ =
|
i i 1 + [ seq nth-unsafe ] bi@ 2dup quot call +gt+ =
|
||||||
[ i 1 + i [ seq set-nth-unsafe ] bi-curry@ bi* drop t ]
|
[ i 1 + i [ seq set-nth-unsafe ] bi-curry@ bi* 2drop i t ]
|
||||||
[ 2drop ] if
|
[ 2drop ] if
|
||||||
] each
|
] each
|
||||||
] loop drop ; inline
|
] loop drop ; inline
|
||||||
|
|
Loading…
Reference in New Issue