sequences.extras: fix map-concat to be row-polymorphic.

char-rename
John Benediktsson 2016-12-29 12:35:39 -08:00
parent b333343e2b
commit d145548c44
2 changed files with 5 additions and 5 deletions

View 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

View 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 )