
Well, its functional of course: union :: Interval -> Interval -> Interval union i j = Interval { isin x = isin i x || isin j x } intersection :: Interval -> Interval -> Interval intersection i j = Interval { isin x = isin i x && isin j x } Keean. Stijn De Saeger wrote:
That seems like a very clean way to define the sets indeed, but how would you go about implementing operations like intersection, complement etc... on those structures? define some sort of algebra over the functions? or extend such sets by adding elements? hm... sounds interesting,.
thanks, stijn.
On Wed, 27 Oct 2004 11:52:54 +0100, Keean Schupke
wrote: 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