Handbook
Glossary
interval-mod ( i1 i2 -- i3 )
Factor handbook
»
The language
»
Numbers
»
Intervals
»
Interval arithmetic
Prev:
interval/i ( i1 i2 -- i3 )
Next:
interval-rem ( i1 i2 -- i3 )
Vocabulary
math
.
intervals
Inputs
i1
an
interval
i2
an
interval
Outputs
i3
an
interval
Word description
Outputs an interval containing all possible values obtained by applying
mod
to elements of
i1
and
i2
.
Definition
USING:
accessors
combinators
kernel
math
sequences
;
IN:
math.intervals
:
interval-mod
( i1 i2 -- i3 )
{
{
[
over
empty-interval?
]
[
swap
]
}
{
[
dup
empty-interval?
]
[
]
}
{
[
dup
full-interval?
]
[
]
}
[
interval-abs
to>>
first
[
neg
]
keep
(a,b)
]
}
cond
swap
0
[a,a]
interval>=
t
eq?
[
[0,inf]
interval-intersect
]
when
;