[Haskell-cafe] Set of reals...?
Stijn De Saeger
stijndesaeger at gmail.com
Wed Oct 27 08:36:55 EDT 2004
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
<k.schupke at imperial.ac.uk> 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
>
>
More information about the Haskell-Cafe
mailing list