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

Brian Beckman bbeckman at exchange.microsoft.com
Fri Oct 29 18:52:37 EDT 2004


Very pretty, Keean, though to get it to work in Hugs Nov 2002 I had to
type the following uglier but equivalent syntax

> myInterval = Interval {
>    isin = (\r ->
>       if r == 0.6 then True else
>       if r > 0.7 && r < 1.0 then True else
>       False )
>    } 

-----Original Message-----
From: haskell-cafe-bounces at haskell.org
[mailto:haskell-cafe-bounces at haskell.org] On Behalf Of Keean Schupke
Sent: Wednesday, October 27, 2004 3:53 AM
To: Stijn De Saeger
Cc: haskell-cafe at haskell.org
Subject: Re: [Haskell-cafe] Set of reals...?

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
   



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


More information about the Haskell-Cafe mailing list