find-integer-from ( ... i n quot: ( ... i -- ... ? ) -- ... i/f )


Vocabulary
math

Inputs
ian integer
nan integer
quota quotation with stack effect ( ... i -- ... ? )


Outputs
i/fan integer or f


Word description
Applies the quotation to each integer from i up to n, excluding n. Iteration stops when the quotation outputs a true value or the end is reached. If the quotation yields a true value for some integer, this word outputs that integer. Otherwise, this word outputs f.

Notes
This word is used to implement find-integer and find.

Definition


: find-integer-from
( ... i n quot: ( ... i -- ... ? ) -- ... i/f )
2over < [
[ nip call ] 3check
[ 2drop ] [ [ 1 + ] 2dip find-integer-from ] if
] [ 3drop f ] if ; inline recursive