! Copyright (C) 2008, 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays combinators kernel locals math
-math.order sequences sequences.private vectors ;
+USING: arrays combinators kernel math math.order sequences
+sequences.private vectors ;
IN: binary-search
<PRIVATE
PRIVATE>
: search ( seq quot: ( elt -- <=> ) -- i elt )
- over empty? [ 2drop f f ] [ [ 0 over length ] dip (search) ] if ;
- inline
+ over empty? [ 2drop f f ] [ [ 0 over length ] dip (search) ] if ; inline
GENERIC: natural-search ( obj seq -- i elt )
M: object natural-search [ <=> ] with search ;