Handbook
Glossary
<interval> ( from to -- interval )
Vocabulary
math
.
intervals
Inputs
from
a
{ point included? }
pair
to
a
{ point included? }
pair
Outputs
interval
an
interval
Word description
Creates a new interval. Usually it is more convenient to create intervals using one of the following words instead:
•
[a,b]
•
(a,b)
•
[a,b)
•
(a,b]
•
[a,inf]
•
(a,inf]
•
[-inf,b)
•
[-inf,b]
Definition
USING:
combinators
kernel
math
sequences
;
IN:
math.intervals
:
<interval>
( from to -- interval )
{
{
[
2dup
[
first
]
bi@
>
]
[
2drop
empty-interval
]
}
{
[
2dup
[
first
]
bi@
number=
]
[
2dup
[
second
]
both?
[
interval
boa
]
[
2drop
empty-interval
]
if
]
}
{
[
2dup
[
{
-1/0.
t
}
=
]
[
{
1/0.
t
}
=
]
bi*
and
]
[
2drop
full-interval
]
}
[
interval
boa
]
}
cond
;