dlist-find ( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f ? )
Factor handbook » The language » Collections » Double-linked lists

Prev:dlist-each ( ... dlist quot: ( ... value -- ... ) -- ... )
Next:dlist-filter ( ... dlist quot: ( ... value -- ... ? ) -- ... dlist' )


Vocabulary
dlists

Inputs
dlistdlist
quota quotation


Outputs
obj/fan object or f
?a boolean


Word description
Applies the quotation to each element of the dlist in turn, until it outputs a true value or the end of the dlist is reached. Outputs either the object it found or f, and a boolean which is true if an object is found.

Notes
Returns a boolean to allow dlists to store f.

This operation is O(n).

Definition


: dlist-find
( ... dlist quot: ( ... value -- ... ? ) -- ... obj/f ? )
[ [ obj>> ] ] dip compose dlist-find-node
[ obj>> t ] [ f f ] if* ; inline