{ $values { "list1" "a list" } { "list2" "a list" } { "result" "lazy list merging list1 and list2" } }
{ $description "Return the result of merging the two lists in a lazy manner." }
{ $examples
- { $example "USING: lazy-lists prettyprint ;" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" }
+ { $example "USING: lists.lazy prettyprint ;" "{ 1 2 3 } >list { 4 5 6 } >list lmerge list>array ." "{ 1 4 2 5 3 6 }" }
} ;
HELP: lcontents
: atom? ( obj -- ? ) [ list? ] [ nil? ] bi or not ;
-: nil ( -- +nil+ ) +nil+ ;
+: nil ( -- symbol ) +nil+ ;
: uncons ( cons -- cdr car )
[ cdr ] [ car ] bi ;
: lmap ( list quot -- result )
over nil? [ drop ] [ (leach) lmap cons ] if ; inline
-: foldl ( list ident quot -- result ) swapd leach ; inline
+: foldl ( list identity quot -- result ) swapd leach ; inline
-: foldr ( list ident quot -- result )
+: foldr ( list identity quot -- result )
pick nil? [ [ drop ] [ ] [ drop ] tri* ] [
[ [ cdr ] 2dip foldr ] [ nip [ car ] dip ] 3bi
call