sequences.extras: adding join-with.

windows-high-dpi
John Benediktsson 2018-02-15 14:46:19 -08:00
parent 03141d93c1
commit 58e77d10f9
2 changed files with 9 additions and 0 deletions

View File

@ -262,3 +262,7 @@ tools.test vectors vocabs ;
{ { 4 5 6 7 } } [ 8 <iota> [ 4 < ] drop-while >array ] unit-test { { 4 5 6 7 } } [ 8 <iota> [ 4 < ] drop-while >array ] unit-test
{ { 15 16 } } [ { 15 16 } [ 4 < ] drop-while >array ] unit-test { { 15 16 } } [ { 15 16 } [ 4 < ] drop-while >array ] unit-test
{ { } } [ 3 <iota> [ 4 < ] drop-while >array ] unit-test { { } } [ 3 <iota> [ 4 < ] drop-while >array ] unit-test
{ { } } [ { } ", " join-with ] unit-test
{ { 1 } } [ { 1 } ", " join-with ] unit-test
{ { 1 ", " 2 } } [ { 1 2 } ", " join-with ] unit-test

View File

@ -625,3 +625,8 @@ PRIVATE>
: drop-while ( ... seq quot: ( ... elt -- ... ? ) -- tail-slice ) : drop-while ( ... seq quot: ( ... elt -- ... ? ) -- tail-slice )
[ '[ @ not ] find drop ] 2keep drop swap [ '[ @ not ] find drop ] 2keep drop swap
[ dup length ] unless* tail-slice ; inline [ dup length ] unless* tail-slice ; inline
: join-with ( seq glue -- newseq )
V{ } clone [
[ '[ _ _ push ] ] [ '[ _ push ] ] bi interleave
] keep { } like ;