factory-0.0.0.2: Rational arithmetic in an irrational world.

Factory.Data.Bounds

Contents

Description

AUTHOR
Dr. Alistair Ward
DESCRIPTION
  • Describes a bounded range of, typically integral, quantities.
  • Operations have been defined, on the list of consecutive quantities delimited by these two bounds.
  • 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.

Synopsis

Types

Type-synonyms

type Bounds limit = (limit, limit)Source

Defines a range of consecutive values, bracketed by inclusive bounds.

Functions

elem' :: Ord limit => limit -> Bounds limit -> BoolSource

True if the specified value is within the inclusive Bounds.

length' :: (Num limit, Ord limit) => Bounds limit -> limitSource

The length of toList.

normalise :: Ord limit => Bounds limit -> Bounds limitSource

Swap the limits where they were originally reversed, but otherwise do nothing.

product'Source

Arguments

:: Integral i 
=> Ratio i

The ratio at which to bisect the Bounds.

-> i

For efficiency, the bounds will not be bisected, when it's length has been reduced to this value.

-> Bounds i 
-> i

The resulting product.

  • Multiplies the consecutive sequence of integers within Bounds.
  • 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.

splitAt' :: (Num limit, Ord limit) => limit -> Bounds limit -> (Bounds limit, Bounds limit)Source

Bisect the bounds at the specified limit; which should be between the two existing limits.

toList :: Enum limit => Bounds limit -> [limit]Source

Converts Bounds to a list by enumerating the values.

Accessors

minBound' :: Bounds a -> aSource

Accessor.

maxBound' :: Bounds a -> aSource

Accessor.

Predicates