elem of infinite set of tuple

View: New views
2 Messages — Rating Filter:   Alert me  

elem of infinite set of tuple

by leledumbo :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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 interpreter 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 Hugs handles this.

From my point of view, instead of starting from (1,0), Hugs starts from (0,0), which will never finish since the limit of the second element is infinite.

Re: elem of infinite set of tuple

by Neil Mitchell :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

This is not the right emailing list for this - its not a bug in Hugs,
just the way Haskell works. I recommend you resend this email to
haskell-cafe -AT- haskell.org - that is a more general list and people
will be happy to help, plus you'll reach a much bigger audience.

Alternatively, hop on to IRC: http://www.haskell.org/haskellwiki/IRC_channel

There people will be happy to answer your questions in real time :)

Thanks

Neil

>  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 interpreter 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 Hugs
>  handles this.
>
>  >From my point of view, instead of starting from (1,0), Hugs starts from
>  (0,0), which will never finish since the limit of the second element is
>  infinite.
>
> --
>  View this message in context: http://www.nabble.com/elem-of-infinite-set-of-tuple-tp17268995p17268995.html
>  Sent from the Haskell - Hugs-Bugs mailing list archive at Nabble.com.
>
>  _______________________________________________
>  Hugs-Bugs mailing list
>  Hugs-Bugs@...
>  http://www.haskell.org/mailman/listinfo/hugs-bugs
>
_______________________________________________
Hugs-Bugs mailing list
Hugs-Bugs@...
http://www.haskell.org/mailman/listinfo/hugs-bugs