insert ( ... seq quot: ( ... elt -- ... elt' ) n -- ... )


Vocabulary
sorting.insertion.private

Inputs
seqan object
quota quotation with stack effect ( ... elt -- ... elt' )
nan object


Outputs
None

Definition


:: insert ( ... seq quot: ( ... elt -- ... elt' ) n -- ... )
n zero? [
n n 1 - [ seq nth-unsafe ] bi@ 2dup [ quot call ] bi@ >=
[ 2drop ] [
n 1 - n [ seq set-nth-unsafe ] bi-curry@ bi*
seq quot n 1 - insert
] if
] unless ; inline recursive