[Haskell-cafe] Set of reals...?
Cale Gibbard
cgibbard at gmail.com
Wed Oct 27 09:10:15 EDT 2004
This has already been mostly answered by Ben's post, but to rephrase
this, basically you do intersection by producing the function which
returns the AND of the two functions given, and union by producing the
function which gives the OR of the two functions given. Complement is
just logical NOT. Basically, any set operation you want turns into a
logical operation using as information just a single arbitrary point,
and the two (or more) predicates given. You can also do arithmetic on
the sets by modifying the incoming point in a suitable way before
passing it on to the predicate.
- Cale
On Wed, 27 Oct 2004 21:36:55 +0900, Stijn De Saeger
<stijndesaeger at gmail.com> 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
>
>
> <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
> >
> >
> _______________________________________________
> 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