Handbook
Glossary
interval-abs ( i1 -- i2 )
Factor handbook
»
The language
»
Numbers
»
Intervals
»
Interval arithmetic
Prev:
interval-2/ ( i1 -- i2 )
Next:
interval-log2 ( i1 -- i2 )
Vocabulary
math
.
intervals
Inputs
i1
an
interval
Outputs
i2
an
interval
Word description
Absolute value of an interval.
Examples
USING: math.intervals prettyprint ; -11 -10 [a,b] interval-abs .
T{ interval { from { 10 t } } { to { 11 t } } }
Definition
USING:
combinators
kernel
sequences
;
IN:
math.intervals
:
interval-abs
( i1 -- i2 )
{
{
[
dup
empty-interval?
]
[
]
}
{
[
dup
full-interval?
]
[
drop
[0,inf]
]
}
{
[
0
over
interval-contains?
]
[
(interval-abs)
{
0
t
}
suffix
points>interval
nan-not-ok
]
}
[
(interval-abs)
points>interval
nan-not-ok
]
}
cond
;