[Haskell-cafe] Set of reals...?

Keean Schupke k.schupke at imperial.ac.uk
Wed Oct 27 06:52:54 EDT 2004


I think someone else mentioned using functions earlier,
rather than a datatype why not define:

    data Interval = Interval { isin :: Float -> Bool }

Then each range becomes a function definition, for example:

    myInterval = Interval {
       isin r
          | r == 0.6 = True
          | r > 0.7 && r < 1.0 = True
          | otherwise = False
       }

Then you can test with:

    (isin myInterval 0.6)

Keean
   





More information about the Haskell-Cafe mailing list