sequences.extras: faster join-with.

If we initialize the array with the glue, then we just set every
other element from the input sequence.
windows-high-dpi
John Benediktsson 2018-02-15 15:03:28 -08:00
parent 7f5f4c348a
commit 112d374aed
1 changed files with 2 additions and 3 deletions

View File

@ -627,6 +627,5 @@ PRIVATE>
[ dup length ] unless* tail-slice ; inline
: join-with ( seq glue -- newseq )
V{ } clone [
[ '[ _ _ push ] ] [ '[ _ push ] ] bi interleave
] keep { } like ;
[ dup length dup 1 - + 0 max ] dip <array>
[ '[ 2 * _ set-nth-unsafe ] each-index ] keep ;