diff --git a/contrib/lazy-lists/lists.factor b/contrib/lazy-lists/lists.factor index b495c3f654..d1086b9204 100644 --- a/contrib/lazy-lists/lists.factor +++ b/contrib/lazy-lists/lists.factor @@ -247,3 +247,19 @@ M: lazy-from-by cdr ( lazy-from-by -- cdr ) M: lazy-from-by nil? ( lazy-from-by -- bool ) drop f ; + +TUPLE: lazy-zip list1 list2 ; + +: lzip ( list1 list2 -- lazy-zip ) + over nil? over nil? or + [ 2drop nil ] [ ] if ; + +M: lazy-zip car ( lazy-zip -- car ) + [ lazy-zip-list1 car ] keep lazy-zip-list2 car 2array ; + +M: lazy-zip cdr ( lazy-zip -- cdr ) + [ lazy-zip-list1 cdr ] keep lazy-zip-list2 cdr lzip ; + +M: lazy-zip nil? ( lazy-zip -- bool ) + drop f ; + \ No newline at end of file