Handbook
Glossary
bounds-check? ( n seq -- ? )
Factor handbook
»
The language
»
Collections
»
Sequence operations
»
Testing sequences
Prev:
empty? ( seq -- ? )
Next:
member? ( elt seq -- ? )
Vocabulary
sequences
Inputs
n
an
integer
seq
a
sequence
Outputs
?
a
boolean
Word description
Tests if the index is within the bounds of the sequence.
Examples
USING: prettyprint sequences ; 5 { 1 2 3 } bounds-check? .
f
Definition
IN:
sequences
GENERIC#:
bounds-check?
1
( n seq -- ? )
Methods
USING:
kernel
math
sequences
;
M:
integer
bounds-check?
dupd
length
<
[
0
>=
]
[
drop
f
]
if
;
inline