Handbook
Glossary
short-groups ( seq n -- seq' )
Vocabulary
grouping
.
extras
Inputs
seq
a
sequence
n
an
integer
Outputs
seq'
a
sequence
Word description
If the length of
seq
is divisible by
n
, return the sequence as is. Otherwise, trim it at the end to fit that requirement.
Returns a virtual sequence.
Definition
USING:
kernel
math
sequences
;
IN:
grouping.extras
::
short-groups
( seq n -- seq' )
seq
dup
length
dup
n
mod
[
drop
]
[
-
head-slice
]
if-zero
;