lzip ( list1 list2 -- result ) (original) (raw)

lzip ( list1 list2 -- result )
Lazy lists » Manipulating lazy lists

Prev: ltake ( list n -- result )

Vocabulary
lists.lazy

Inputs

list1 a cons object
list2 a cons object

Outputs

result a lazy list

Word description
Performs a similar functionality to that of the zip word, but in a lazy manner.

Examples

USING: kernel lists lists.lazy math prettyprint ; 1 lfrom 10 [ 10 + ] lfrom-by lzip 5 ltake list>array .
{ { 1 10 } { 2 20 } { 3 30 } { 4 40 } { 5 50 } }

Definition

USING: kernel lists ;

IN: lists.lazy

: lzip ( list1 list2 -- result )
2dup [ nil? ] either? [ 2drop nil ] [ ] if ;