insertion-unsort ( str extended -- deltas )


Vocabulary
punycode.private

Inputs
stran object
extendedan object


Outputs
deltasan object


Definition


:: insertion-unsort ( str extended -- deltas )
V{ } clone :> accum N :> oldch! -1 :> oldi! extended [| ch |
-1 :> i! -1 :> pos! str [ ch < ] count
:> curlen curlen 1 + ch oldch - * :> delta! [
str ch i pos find-pos pos! i! i -1 =
[ f ] [
i oldi - delta + delta! delta 1 - accum push
i oldi! 0 delta! t
] if
] loop ch oldch!
] each accum ;