"Brian Hulley" <[EMAIL PROTECTED]> wrote:


   What about a library for interval arithmetic [1]?

   I'd imagine it could start something like:

   data Interval a = Interval !a !a deriving (Eq, Show)

   instance Num a => Num (Interval a) where

   Interval llow lhigh + Interval rlow rhigh = Interval (min llow rlow)
   (max lhigh rhigh)

   The Interval type would probably need to explicitly represent
   several kinds
   of intervals eg (-infinity, x] etc and there are some tricky issues
   about
   what to do with the operations whose result sometimes needs to be
   represented by more than one interval to be useful such as division
   by an
   interval containing zero eg you might want to use a list of
   intervals to
   deal with these cases:

   instance Num a => [Interval a] where
   ...

   ie
   [Interval 5 5] / [Interval -1 1] = [FromNegInfinityTo -5,
   ToPosInfinityFrom 5]

Take a look at my Ranged Sets library at

http://sourceforge.net/projects/ranged-sets

Paul.
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to