Handbook
Glossary
interval-in? ( key set -- ? )
Interval sets
Prev:
<interval-set> ( specification -- interval-set )
Next:
<interval-not> ( set maximum -- set' )
Vocabulary
interval-sets
Inputs
key
an
integer
set
an
interval-set
Outputs
?
t
or
f
Word description
Tests whether an integer is in an interval set. This takes O(log n) time for an interval map composed of n intervals.
Definition
USING:
accessors
binary-search
classes
kernel
math
math.order
;
IN:
interval-sets
:
interval-in?
( key set -- ? )
interval-set
check-instance
array>>
dupd
[
<=>
]
with
search
swap
[
even?
[
>=
]
[
1
-
<=
]
if
]
[
2drop
f
]
if*
;