Vocabulary
math

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


Outputs
i/fan integer or f


Word description
Applies the quotation to each integer from n down to 0, inclusive. Iteration stops when the quotation outputs a true value or 0 is reached. If the quotation yields a true value for some integer, the word outputs that integer. Otherwise, the word outputs f.

Notes
This word is used to implement find-last.

Definition


: find-last-integer
( ... n quot: ( ... i -- ... ? ) -- ... i/f )
over 0 <
[ 2drop f ] [
[ call ] 2keep rot
[ drop ] [ [ 1 - ] dip find-last-integer ] if
] if ; inline recursive