Handbook
Glossary
split-indices ( seq indices -- pieces )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Splitting sequences
Prev:
split ( seq separators -- pieces )
Next:
split-slice ( seq separators -- pieces )
Vocabulary
splitting
Inputs
seq
a
sequence
indices
a
sequence
Outputs
pieces
a new array
Word description
Splits a sequence at the given indices.
Examples
USING: prettyprint splitting ; "hello world" { 3 6 } split-indices .
{ "hel" "lo " "world" }
Definition
USING:
kernel
sequences
;
IN:
splitting
:
split-indices
( seq indices -- pieces )
over
length
suffix
0
swap
[
[
pick
subseq
]
1check
]
map
2nip
;