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.
- type Bounds limit = (limit, limit)
- elem' :: Ord limit => limit -> Bounds limit -> Bool
- length' :: (Num limit, Ord limit) => Bounds limit -> limit
- normalise :: Ord limit => Bounds limit -> Bounds limit
- product' :: Integral i => Ratio i -> i -> Bounds i -> i
- splitAt' :: (Num limit, Ord limit) => limit -> Bounds limit -> (Bounds limit, Bounds limit)
- toList :: Enum limit => Bounds limit -> [limit]
- minBound' :: Bounds a -> a
- maxBound' :: Bounds a -> a
Types
Type-synonyms
type Bounds limit = (limit, limit)Source
Defines a range of consecutive values, bracketed by inclusive bounds.
Functions
normalise :: Ord limit => Bounds limit -> Bounds limitSource
Swap the limits where they were originally reversed, but otherwise do nothing.
:: Integral i | |
=> Ratio i | The ratio at which to bisect the |
-> 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.