lists.lazy: fix luntil
parent
ad29cb21f9
commit
ddd13c8979
|
@ -35,5 +35,7 @@ IN: lists.lazy.tests
|
|||
[ [ drop ] leach ] must-infer
|
||||
[ lnth ] must-infer
|
||||
|
||||
[ { 1 2 3 } ] [ { 1 2 3 4 5 } >list [ 2 > ] luntil list>array ] unit-test
|
||||
|
||||
[ ] [ "resource:license.txt" utf8 <file-reader> llines list>array drop ] unit-test
|
||||
[ ] [ "resource:license.txt" utf8 <file-reader> lcontents list>array drop ] unit-test
|
||||
|
|
|
@ -111,14 +111,15 @@ C: <lazy-until> lazy-until
|
|||
over nil? [ drop ] [ <lazy-until> ] if ;
|
||||
|
||||
M: lazy-until car ( lazy-until -- car )
|
||||
cons>> car ;
|
||||
cons>> car ;
|
||||
|
||||
M: lazy-until cdr ( lazy-until -- cdr )
|
||||
[ quot>> ] [ cons>> unswons ] bi over call( elt -- ? )
|
||||
[ 2drop nil ] [ luntil ] if ;
|
||||
[ [ cons>> cdr ] [ quot>> ] bi ]
|
||||
[ [ cons>> car ] [ quot>> ] bi call( elt -- ? ) ] bi
|
||||
[ 2drop nil ] [ luntil ] if ;
|
||||
|
||||
M: lazy-until nil? ( lazy-until -- ? )
|
||||
drop f ;
|
||||
drop f ;
|
||||
|
||||
TUPLE: lazy-while cons quot ;
|
||||
|
||||
|
@ -128,13 +129,13 @@ C: <lazy-while> lazy-while
|
|||
over nil? [ drop ] [ <lazy-while> ] if ;
|
||||
|
||||
M: lazy-while car ( lazy-while -- car )
|
||||
cons>> car ;
|
||||
cons>> car ;
|
||||
|
||||
M: lazy-while cdr ( lazy-while -- cdr )
|
||||
[ cons>> cdr ] keep quot>> lwhile ;
|
||||
[ cons>> cdr ] keep quot>> lwhile ;
|
||||
|
||||
M: lazy-while nil? ( lazy-while -- ? )
|
||||
[ car ] keep quot>> call( elt -- ? ) not ;
|
||||
[ car ] keep quot>> call( elt -- ? ) not ;
|
||||
|
||||
TUPLE: lazy-filter cons quot ;
|
||||
|
||||
|
|
Loading…
Reference in New Issue