Handbook
Glossary
interval-intersect ( i1 i2 -- i3 )
Factor handbook
»
The language
»
Numbers
»
Intervals
»
Set-theoretic operations on intervals
Prev:
interval-subset? ( i1 i2 -- ? )
Next:
interval-union ( i1 i2 -- i3 )
Vocabulary
math
.
intervals
Inputs
i1
an
interval
i2
an
interval
Outputs
i3
an
interval
or
f
Word description
Outputs the set-theoretic intersection of
i1
and
i2
. If
i1
and
i2
do not intersect, outputs
f
.
See also
interval-union
Definition
USING:
combinators
kernel
;
IN:
math.intervals
:
interval-intersect
( i1 i2 -- i3 )
{
{
[
over
empty-interval?
]
[
drop
]
}
{
[
dup
empty-interval?
]
[
nip
]
}
{
[
over
full-interval?
]
[
nip
]
}
{
[
dup
full-interval?
]
[
drop
]
}
[
[
interval>points
]
bi@
[
[
swap
endpoint<
]
most
]
[
[
swap
endpoint>
]
most
]
bi-curry*
bi*
<interval>
]
}
cond
;