{ "llohe" } [ "hello" 2 rotate ] unit-test
{ "hello" } [ "hello" dup 0 rotate! ] unit-test
{ "lohel" } [ "hello" dup 3 rotate! ] unit-test
+
+{ { } } [ { } [ ] map-concat ] unit-test
+{ V{ 0 0 1 0 1 2 } } [ 4 iota [ iota ] map-concat ] unit-test
+{ "abc" } [ "abc" [ 1string ] map-concat ] unit-test
+{ { 97 98 99 } } [ "abc" [ 1string ] { } map-concat-as ] unit-test
dup end = [ drop over ] when
2over = [ -rot nip over ] when
] until 3drop ;
+
+: appender-for ( quot exemplar -- quot' vec )
+ [ length ] keep new-resizable
+ [ [ push-all ] curry compose ] keep ; inline
+
+: appender ( quot -- quot' vec )
+ V{ } appender-for ; inline
+
+: map-concat-as ( ... seq quot: ( ... elt -- ... newelt ) exemplar -- ... newseq )
+ dup [ appender-for [ each ] dip ] curry dip like ; inline
+
+: map-concat ( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
+ over map-concat-as ; inline