
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@haskell.org [mailto:haskell-cafe-bounces@haskell.org] On Behalf Of Keean Schupke Sent: Wednesday, October 27, 2004 3:53 AM To: Stijn De Saeger Cc: haskell-cafe@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@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (1)
-
Brian Beckman