Copyright | (c) Masahiro Sakai 2016 |
---|---|
License | BSD-style |
Maintainer | masahiro.sakai@gmail.com |
Stability | provisional |
Portability | non-portable (CPP, ScopedTypeVariables, TypeFamilies, DeriveDataTypeable, MultiWayIf) |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
Interval datatype and interval arithmetic.
Synopsis
- data IntervalSet r
- module Data.ExtendedReal
- whole :: Ord r => IntervalSet r
- empty :: Ord r => IntervalSet r
- singleton :: Ord r => Interval r -> IntervalSet r
- null :: IntervalSet r -> Bool
- member :: Ord r => r -> IntervalSet r -> Bool
- notMember :: Ord r => r -> IntervalSet r -> Bool
- isSubsetOf :: Ord r => IntervalSet r -> IntervalSet r -> Bool
- isProperSubsetOf :: Ord r => IntervalSet r -> IntervalSet r -> Bool
- span :: Ord r => IntervalSet r -> Interval r
- complement :: Ord r => IntervalSet r -> IntervalSet r
- insert :: Ord r => Interval r -> IntervalSet r -> IntervalSet r
- delete :: Ord r => Interval r -> IntervalSet r -> IntervalSet r
- union :: Ord r => IntervalSet r -> IntervalSet r -> IntervalSet r
- unions :: Ord r => [ IntervalSet r] -> IntervalSet r
- intersection :: Ord r => IntervalSet r -> IntervalSet r -> IntervalSet r
- intersections :: Ord r => [ IntervalSet r] -> IntervalSet r
- difference :: Ord r => IntervalSet r -> IntervalSet r -> IntervalSet r
- fromList :: Ord r => [ Interval r] -> IntervalSet r
- toList :: Ord r => IntervalSet r -> [ Interval r]
- toAscList :: Ord r => IntervalSet r -> [ Interval r]
- toDescList :: Ord r => IntervalSet r -> [ Interval r]
- fromAscList :: Ord r => [ Interval r] -> IntervalSet r
IntervalSet type
data IntervalSet r Source #
A set comprising zero or more non-empty, disconnected intervals.
Any connected intervals are merged together, and empty intervals are ignored.
Instances
module Data.ExtendedReal
Construction
whole :: Ord r => IntervalSet r Source #
whole real number line (-∞, ∞)
empty :: Ord r => IntervalSet r Source #
empty interval set
Query
null :: IntervalSet r -> Bool Source #
Is the interval set empty?
isSubsetOf :: Ord r => IntervalSet r -> IntervalSet r -> Bool Source #
Is this a subset?
(is1 `
tells whether
isSubsetOf
` is2)
is1
is a subset of
is2
.
isProperSubsetOf :: Ord r => IntervalSet r -> IntervalSet r -> Bool Source #
Is this a proper subset? ( i.e. a subset but not equal).
Construction
complement :: Ord r => IntervalSet r -> IntervalSet r Source #
Complement the interval set.
insert :: Ord r => Interval r -> IntervalSet r -> IntervalSet r Source #
Insert a new interval into the interval set.
delete :: Ord r => Interval r -> IntervalSet r -> IntervalSet r Source #
Delete an interval from the interval set.
Combine
union :: Ord r => IntervalSet r -> IntervalSet r -> IntervalSet r Source #
union of two interval sets
unions :: Ord r => [ IntervalSet r] -> IntervalSet r Source #
union of a list of interval sets
intersection :: Ord r => IntervalSet r -> IntervalSet r -> IntervalSet r Source #
intersection of two interval sets
intersections :: Ord r => [ IntervalSet r] -> IntervalSet r Source #
intersection of a list of interval sets
difference :: Ord r => IntervalSet r -> IntervalSet r -> IntervalSet r Source #
difference of two interval sets
Conversion
List
fromList :: Ord r => [ Interval r] -> IntervalSet r Source #
Build a interval set from a list of intervals.
toList :: Ord r => IntervalSet r -> [ Interval r] Source #
Convert a interval set into a list of intervals.
Ordered list
toAscList :: Ord r => IntervalSet r -> [ Interval r] Source #
Convert a interval set into a list of intervals in ascending order.
toDescList :: Ord r => IntervalSet r -> [ Interval r] Source #
Convert a interval set into a list of intervals in descending order.
fromAscList :: Ord r => [ Interval r] -> IntervalSet r Source #
Build a map from an ascending list of intervals. The precondition is not checked.