Vocabulary

binary-search.private

Inputs

Outputs

Definition

binary-search.private

Inputs

seq | an object |

from | an object |

to | an object |

quot | a quotation with stack effect ( ... elt -- ... <=> ) |

Outputs

i | an object |

elt | an 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

( ... 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

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.101 x86.64 (2282, heads/master-74be1555ff, Sep 25 2024 19:43:38)