Handbook
Glossary
interleaved-as ( seq glue exemplar -- newseq )
Vocabulary
sequences
.
extras
Inputs
seq
a
sequence
glue
an
object
exemplar
an
object
Outputs
newseq
a
sequence
Word description
Insert
glue
between every pair of elements in
seq
. Resulting sequence will be the same class as
exemplar
.
Definition
USING:
kernel
math
math.order
sequences
sequences.private
;
IN:
sequences.extras
::
interleaved-as
( seq glue exemplar -- newseq )
seq
length
dup
1
-
+
0
max
exemplar
new-sequence
:>
newseq seq
[
2
*
newseq
set-nth-unsafe
]
each-index
seq
length
1
-
[
2
*
1
+
glue
swap
newseq
set-nth-unsafe
]
each-integer
newseq
;