Handbook
Glossary
interleave ( ... seq between quot: ( ... elt -- ... ) -- ... )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Sequence combinators
Prev:
reduce ( ... seq identity quot: ( ... prev elt -- ... next ) -- ... result )
Next:
map ( ... seq quot: ( ... elt -- ... newelt ) -- ... newseq )
Vocabulary
sequences
Inputs
seq
a
sequence
between
a
quotation
quot
a
quotation
with stack effect
( ... elt -- ... )
Outputs
None
Word description
Applies
quot
to each element in turn, also invoking
between
in-between each pair of elements.
Examples
USING: io sequences ; { "a" "b" "c" } [ "X" write ] [ write ] interleave
aXbXc
Definition
USING:
kernel
sequences.private
;
IN:
sequences
:
interleave
( ... seq between quot: ( ... elt -- ... ) -- ... )
pick
empty?
[
3drop
]
[
[
[
drop
first-unsafe
]
dip
call
]
[
[
bi*
]
2curry
1
each-from
]
3bi
]
if
;
inline