(search) ( ... seq from to quot: ( ... elt -- ... <=> ) -- ... i elt )


Vocabulary
binary-search.private

Inputs
seqan object
froman object
toan object
quota quotation with stack effect ( ... elt -- ... <=> )


Outputs
ian object
eltan object


Definition


:: (search)
( ... seq from to quot: ( ... elt -- ... <=> ) -- ... i elt )
from to + 2/ :> midpoint@ midpoint@ seq nth-unsafe
:> midpoint to from - 1 <=
[ midpoint@ midpoint ] [
midpoint quot call {
{ +lt+ [ seq from midpoint@ quot (search) ] }
{ +gt+ [ seq midpoint@ to quot (search) ] }
{ +eq+ [ midpoint@ midpoint ] }
} case
] if ; inline recursive