It&#39;s not exactly a question of Haskell&#39;s behaviour. The list [ (a,b) | a &lt;- [0..], b &lt;- [0..] ]<br>
is such that apart from pairs starting with zero, no other pair is associated with a finite index. In other words, [ (a,b) | a &lt;- [0..], b &lt;- [0..] ] is not a correct &#39;enumeration&#39; of all pairs of nonnegative integers. You need to reorder them if you need a finite index associated with every pair.<br>
<br><div class="gmail_quote">On Fri, May 16, 2008 at 5:12 PM, leledumbo &lt;<a href="mailto:leledumbo_cool@yahoo.co.id">leledumbo_cool@yahoo.co.id</a>&gt; wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>
I don&#39;t know how Haskell should behave on this. Consider this function:<br>
elemOf (x,y) = (x,y) `elem` [ (a,b) | a &lt;- [0..], b &lt;- [0..] ]<br>
<br>
If I try to query elemOf (1,1), the program keeps searching and searching<br>
but it never makes it. But if I query elemOf (0,1) (or anything as long as<br>
the first element is 0), it can find it easily. I wonder how it&#39;s handled.<br>
<br>
&gt;From my point of view, instead of starting from (1,0), the program starts<br>
from (0,0), which will never finish since the limit of the second element is<br>
infinite.<br>
<font color="#888888">--<br>
View this message in context: <a href="http://www.nabble.com/elem-of-infinite-set-of-tuple-tp17272802p17272802.html" target="_blank">http://www.nabble.com/elem-of-infinite-set-of-tuple-tp17272802p17272802.html</a><br>
Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com.<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</font></blockquote></div><br>