interval

Factor handbook » The language » Numbers » Intervals

Factor handbook » The language » Numbers » Intervals

Prev: | Properties of interval arithmetic |

Next: | interval? ( object -- ? ) |

Vocabulary

math.intervals

Class description

An interval represents a set of real numbers between two endpoints; the endpoints can either be included or excluded from the interval.

The from and to slots store endpoints, represented as arrays of the shape { number included? }.

Intervals are created by calling [a,b], (a,b), [a,b), (a,b] or [a,a].

Definition

Methods

math.intervals

Class description

An interval represents a set of real numbers between two endpoints; the endpoints can either be included or excluded from the interval.

The from and to slots store endpoints, represented as arrays of the shape { number included? }.

Intervals are created by calling [a,b], (a,b), [a,b), (a,b] or [a,a].

Definition

Methods

M: interval interval-contains?

{

[ from>> first2 [ >= ] [ > ] if ]

[ to>> first2 [ <= ] [ < ] if ]

} 2&& ;

{

[ from>> first2 [ >= ] [ > ] if ]

[ to>> first2 [ <= ] [ < ] if ]

} 2&& ;

M: interval interval-log2

to>> first 1 max dup most-positive-fixnum >

[ drop full-interval interval-log2 ]

[ 1 + >integer log2 [0,b] ] if ;

to>> first 1 max dup most-positive-fixnum >

[ drop full-interval interval-log2 ]

[ 1 + >integer log2 [0,b] ] if ;

M: interval interval-singleton?

interval>points 2dup [ second ] both?

[ [ first ] bi@ number= ] [ 2drop f ] if ;

interval>points 2dup [ second ] both?

[ [ first ] bi@ number= ] [ 2drop f ] if ;

This documentation was generated offline from a
`load-all`

image. If you want, you can also
browse the documentation from within the UI developer tools. See
the Factor website
for more information.

Factor 0.100 x86.64 (2263, heads/master-c17b1b6507, Mar 1 2024 15:37:26)