]> gitweb.factorcode.org Git - factor.git/commitdiff
combinators.smart: simpler smart-loop definition.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 4 Apr 2021 14:10:25 +0000 (07:10 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 4 Apr 2021 14:10:25 +0000 (07:10 -0700)
basis/combinators/smart/smart-tests.factor
basis/combinators/smart/smart.factor

index 59e778dd6edac03e48f41b5da5ef26ded9c1daf8..8802549c04fe860edec5f4f66c4b8a524f69a9e5 100644 (file)
@@ -129,4 +129,3 @@ IN: combinators.smart.tests
 { { 1 2 } 3 4 5 6 } [ [ 1 2 3 4 5 6 ] 4 output>array-n ] unit-test
 
 { t } [ [ 10 random dup even? ] smart-loop odd? ] unit-test
-{ t } [ 10 [ random dup even? ] smart-loop odd? ] unit-test
index cce860858f1892872db4cb3af8abae8db5aea150..c2bb719d35e134ca9fc13e4873b5ab852f12dc53 100644 (file)
@@ -162,8 +162,5 @@ MACRO: smart-2map-reduce ( 2map-reduce-quots -- quot )
         1 2each-from
     ] ;
 
-:: smart-loop ( ..a quot: ( ..a -- ..b ? ) -- ..b )
-    quot inputs/outputs :> ( #inputs #outputs )
-    [ quot preserving dup ]
-    [ #outputs ndrop ] while
-    [ #inputs ndrop ] #outputs ndip drop ; inline
+: smart-loop ( ..a quot: ( ..a -- ..b ? ) -- ..b )
+    dup outputs [ ndrop ] curry while* ; inline