Handbook
Glossary
halves ( seq -- first-slice second-slice )
Vocabulary
sequences
Inputs
seq
a
sequence
Outputs
first-slice
a
slice
second-slice
a
slice
Word description
Splits a sequence into two slices at the midpoint. If the sequence has an odd number of elements, the extra element is returned in the second slice.
Examples
USING: arrays sequences prettyprint kernel ; { 1 2 3 4 5 } halves [ >array . ] bi@
{ 1 2 } { 3 4 5 }
Definition
USING:
kernel
;
IN:
sequences
:
halves
( seq -- first-slice second-slice )
dup
midpoint@
cut-slice
;
inline