lazy-lists: fix laziness of lappend
lappend would evaluate the car of the second list all the timedarcs
parent
8586c82066
commit
b66cee04b3
|
@ -281,9 +281,7 @@ TUPLE: lazy-append list1 list2 ;
|
||||||
|
|
||||||
: lappend ( list1 list2 -- result )
|
: lappend ( list1 list2 -- result )
|
||||||
{
|
{
|
||||||
{ [ over nil? over nil? and ] [ 2drop nil ] }
|
|
||||||
{ [ over nil? ] [ nip ] }
|
{ [ over nil? ] [ nip ] }
|
||||||
{ [ dup nil? ] [ drop ] }
|
|
||||||
{ [ t ] [ <lazy-append> ] }
|
{ [ t ] [ <lazy-append> ] }
|
||||||
} cond ;
|
} cond ;
|
||||||
|
|
||||||
|
@ -296,9 +294,9 @@ M: lazy-append cdr ( lazy-append -- cdr )
|
||||||
|
|
||||||
M: lazy-append nil? ( lazy-append -- bool )
|
M: lazy-append nil? ( lazy-append -- bool )
|
||||||
dup lazy-append-list1 nil? [
|
dup lazy-append-list1 nil? [
|
||||||
drop t
|
|
||||||
] [
|
|
||||||
lazy-append-list2 nil?
|
lazy-append-list2 nil?
|
||||||
|
] [
|
||||||
|
drop f
|
||||||
] if ;
|
] if ;
|
||||||
|
|
||||||
M: lazy-append list? ( object -- bool )
|
M: lazy-append list? ( object -- bool )
|
||||||
|
|
Loading…
Reference in New Issue