ltake ( list n -- result )
Lazy lists ยป Manipulating lazy lists

Prev:lmerge ( list1 list2 -- result )
Next:lzip ( list1 list2 -- result )


Vocabulary
lists.lazy

Inputs
lista cons object
na non negative integer


Outputs
resultresulting cons object


Word description
Outputs a lazy list containing the first n items in the list. This is done a lazy manner. No evaluation of the list elements occurs initially but a lazy-take object is returned which conforms to the list protocol. Calling car, cdr or nil? on this will evaluate elements as required.

Examples
USING: kernel lists lists.lazy prettyprint ; 1 lfrom 5 ltake list>array .
{ 1 2 3 4 5 }


See also
leach, foldl, lmap-lazy, lfilter, lappend-lazy, lfrom, lfrom-by, lconcat, lcartesian-product, lcartesian-product*, lcartesian-map, lcartesian-map*, lmerge, lwhile, luntil

Definition