factory-0.2.1.1: Rational arithmetic in an irrational world.

Factory.Data.Interval

Description

`AUTHOR`
Dr. Alistair Ward
`DESCRIPTION`
• Describes a bounded set of, typically integral, quantities.
• Operations have been defined, on the list of consecutive quantities delimited by these endpoints.
• The point is that if the list is composed from consecutive quantities, the intermediate values can be inferred, rather than physically represented.
`CAVEATS`
• The API was driven top-down by its caller's requirements, rather than a bottom-up attempt to provide a complete interface. consequently there may be omissions from the view point of future callers.
• Thought similar to the mathematical concept of an interval, the latter technically relates to real numbers; http://en.wikipedia.org/wiki/Interval_%28mathematics%29.
• No account has been made for semi-closed or open intervals.

Synopsis

# Types

## Type-synonyms

type Interval endPoint = (endPoint, endPoint) Source

Defines a closed (inclusive) interval of consecutive values.

# Constants

Construct the unsigned closed unit-interval; http://en.wikipedia.org/wiki/Unit_interval.

mkBounded :: Bounded endPoint => Interval endPoint Source

Construct an interval from a bounded type.

# Functions

elem' :: Ord endPoint => endPoint -> Interval endPoint -> Bool Source

True if the specified value is within the inclusive bounds of the interval.

normalise :: Ord endPoint => Interval endPoint -> Interval endPoint Source

Swap the end-points where they were originally reversed, but otherwise do nothing.

Arguments

 :: (Integral i, Show i) => Ratio i The ratio at which to bisect the `Interval`. -> i For efficiency, the interval will not be bisected, when it's length has been reduced to this value. -> Interval i -> i The resulting product.
• Multiplies the consecutive sequence of integers within `Interval`.
• Since the result can be large, `divideAndConquer` is used to form operands of a similar order of magnitude, thus improving the efficiency of the big-number multiplication.

Arguments

 :: Num endPoint => endPoint The magnitude of the require shift. -> Interval endPoint The interval to be shifted. -> Interval endPoint

Shift of both end-points of the interval by the specified amount.

splitAt' :: (Enum endPoint, Num endPoint, Ord endPoint, Show endPoint) => endPoint -> Interval endPoint -> (Interval endPoint, Interval endPoint) Source

Bisect the interval at the specified end-point; which should be between the two existing end-points.

toList :: Enum endPoint => Interval endPoint -> [endPoint] Source

• Converts `Interval` to a list by enumerating the values.
• CAVEAT: produces rather odd results for `Fractional` types, but no stranger than considering such types Enumerable in the first place.

## Accessors

getMinBound :: Interval endPoint -> endPoint Source

Accessor.

getMaxBound :: Interval endPoint -> endPoint Source

Accessor.

## Constructors

precisely :: endPoint -> Interval endPoint Source

Construct an interval from a single value.

## Predicates

isReversed :: Ord endPoint => Interval endPoint -> Bool Source

True if `getMinBound` exceeds `getMaxBound` extent.