Handbook
Glossary
shorten ( n seq -- )
Vocabulary
sequences
Inputs
n
an
integer
seq
a
sequence
Outputs
None
Word description
Shortens a
Resizable sequence implementation
sequence to be
n
elements long.
Examples
USING: sequences prettyprint kernel ; V{ 1 2 3 4 5 } 3 over shorten .
V{ 1 2 3 }
Definition
IN:
sequences
GENERIC:
shorten
( n seq -- )
Methods
USING:
accessors
growable
kernel
math
sequences
sequences.private
;
M:
growable
shorten
bounds-check-head
2dup
length
<
[
2dup
contract
2dup
length<<
]
when
2drop
;
inline
USING:
kernel
math
sequences
;
M:
sequence
shorten
[
length
<
]
2check
[
set-length
]
[
2drop
]
if
;
inline