]> gitweb.factorcode.org Git - factor.git/commitdiff
sequences.extras: fix map-concat to be row-polymorphic.
authorJohn Benediktsson <mrjbq7@gmail.com>
Thu, 29 Dec 2016 20:35:39 +0000 (12:35 -0800)
committerJohn Benediktsson <mrjbq7@gmail.com>
Thu, 29 Dec 2016 20:35:39 +0000 (12:35 -0800)
extra/sequences/extras/extras-tests.factor
extra/sequences/extras/extras.factor

index 96e8c7109b60faf4f3d6105dbb93b06533afd64f..28db9fb03f82b5093e5308a5ca53b490c70bae6d 100644 (file)
@@ -107,8 +107,8 @@ IN: sequences.extras.tests
 { "abc" } [ "abc" [ 1string ] map-concat ] unit-test
 { "abc" } [ { 97 98 99 } [ 1string ] map-concat ] unit-test
 { { 97 98 99 } } [ "abc" [ 1string ] { } map-concat-as ] unit-test
-{ { "foobaz" "barbaz" } }
-[ "baz" { { "foo" } { "bar" } } [ [ prepend ] with map ] with map-concat ] unit-test
+{ "baz" { "foobaz" "barbaz" } }
+[ "baz" { { "foo" } { "bar" } } [ [ over append ] map ] map-concat ] unit-test
 
 { { } } [ { } [ ] [ even? ] map-filter ] unit-test
 { "bcde" } [ "abcd" [ 1 + ] [ drop t ] map-filter ] unit-test
index 3d7d89d8d93e062296146bdb719787bc0b84b1ad..8d2805473cbd0198f381e44334f91d35beb53ee7 100644 (file)
@@ -230,9 +230,9 @@ PRIVATE>
 
 : map-concat ( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
     over empty? [ 2drop { } ] [
-        [ [ first ] dip call ] 2keep pick [
-            [ >resizable ] 2dip [ append! ] compose 1 each-from
-        ] dip like
+        [ [ first ] dip call ] 2keep rot [
+            >resizable [ '[ @ _ push-all ] 1 each-from ] keep
+        ] keep like
     ] if ; inline
 
 : map-filter-as ( ... seq map-quot: ( ... elt -- ... newelt ) filter-quot: ( ... newelt -- ... ? ) exemplar -- ... subseq )