]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences: fix filter! to allow stack arguments to be used by the quot.
authorJohn Benediktsson <mrjbq7@gmail.com>
Sun, 5 Mar 2017 22:09:03 +0000 (14:09 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Sun, 5 Mar 2017 22:09:03 +0000 (14:09 -0800)
core/sequences/sequences-tests.factor
core/sequences/sequences.factor

index cada259e7560f6a02260bd64be0d4b18e23ac8a6..a91bf4e1007b940da8b2f984268a2d420e14bf11 100644 (file)
@@ -93,6 +93,7 @@ IN: sequences.tests
 { V{ 4 2 6 } } [ V{ 1 4 2 5 3 6 } clone [ 2 mod 0 = ] filter! ] unit-test
 
 { V{ 3 } } [ V{ 1 2 3 } clone 2 [ swap < ] curry filter! ] unit-test
+{ 4 V{ 1 2 3 } } [ 4 V{ 1 4 2 5 3 6 } [ dupd > ] filter! ] unit-test
 
 { "hello world how are you" }
 [ { "hello" "world" "how" "are" "you" } " " join ] unit-test
index 7fbb53ed5fc954859b3a3ae7ccae0c6cc4dd2e60..392ed174e6ec940144a1703e64453cbfac48cfe9 100644 (file)
@@ -724,7 +724,7 @@ M: slice equal? over slice? [ sequence= ] [ 2drop f ] if ;
 : (filter!) ( ... quot: ( ... elt -- ... ? ) store scan seq -- ... )
     2dup length < [
         [ move-unsafe ] 3keep
-        [ nth-unsafe pick call [ 1 + ] when ] 2keep
+        [ nth-unsafe -rot [ [ call ] keep ] dip rot [ 1 + ] when ] 2keep
         [ 1 + ] dip
         (filter!)
     ] [ nip set-length drop ] if ; inline recursive