]> gitweb.factorcode.org Git - factor.git/commitdiff
lists.lazy: fix luntil
authorSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 6 Nov 2009 10:31:22 +0000 (04:31 -0600)
committerSlava Pestov <slava@slava-pestovs-macbook-pro.local>
Fri, 6 Nov 2009 10:31:22 +0000 (04:31 -0600)
basis/lists/lazy/lazy-tests.factor
basis/lists/lazy/lazy.factor

index 8fb638b8566992c52016260beeec9aa137d8b153..39f92158a68bbff851097c1b6a8f6fe70e2248ed 100644 (file)
@@ -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
index 57cacaa4945c6d83bf56bf317c65ab236ec51ab7..122a2205dd27664e73877879862cfde7c8daf908 100644 (file)
@@ -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 ;