[Haskell-cafe] elem of infinite set of tuple

David Roundy droundy at darcs.net
Fri May 16 07:49:16 EDT 2008


On Fri, May 16, 2008 at 04:42:31AM -0700, leledumbo wrote:
> 
> I don't know how Haskell should behave on this. Consider this function:
> elemOf (x,y) = (x,y) `elem` [ (a,b) | a <- [0..], b <- [0..] ]
> 
> If I try to query elemOf (1,1), the program keeps searching and searching
> but it never makes it. But if I query elemOf (0,1) (or anything as long as
> the first element is 0), it can find it easily. I wonder how it's handled.
> 
> From my point of view, instead of starting from (1,0), the program starts
> from (0,0), which will never finish since the limit of the second element is
> infinite.

Didn't you just answer your own question?
-- 
David Roundy
Department of Physics
Oregon State University


More information about the Haskell-Cafe mailing list