lwhile ( list quot: ( elt -- ? ) -- result ) (original) (raw)
Inputs
list | a cons object |
---|---|
quot | a quotation with stack effect ( elt -- ? ) |
Outputs
result | resulting cons object |
---|
Word description
Outputs a lazy list containing the first items in the list as long as quot evaluates to t. No evaluation of the list elements occurs initially but a lazy-while object is returned with conforms to the list protocol. Calling car, cdr or nil? on this will evaluate elements as required.
Examples
USING: kernel lists lists.lazy math prettyprint ; 1 lfrom [ 5 <= ] lwhile list>array .
{ 1 2 3 4 5 }
See also
leach, foldl, lmap-lazy, ltake, lfilter, lappend-lazy, lfrom, lfrom-by, lconcat, lcartesian-product, lcartesian-product*, lcartesian-map, lcartesian-map*, lmerge, luntil
Definition