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

Ben Rudiak-Gould Benjamin.Rudiak-Gould at cl.cam.ac.uk
Wed Oct 27 05:50:24 EDT 2004


One idea that might not occur to a newcomer is to represent each set by 
a function with a type like (Double -> Bool), implementing the set 
membership operation. This makes set-theoretic operations easy: the 
complement of s is not.s (though watch out for NaNs!), the union of s 
and t is (\x -> s x || t x), and so on. Open, closed, and half-open 
intervals are easy too. The big limitation of this representation is 
that there's no way to inspect a set except by testing particular values 
for membership, but depending on your application this may not be a problem.

-- Ben



More information about the Haskell-Cafe mailing list