According to this construction, enumeration will need some SAT enumeration like process, where you search with a new predicate barring all previous candidates? <br><br><div class="gmail_quote"><div dir="ltr">On Mon, 10 Dec, 2018, 08:50 Doug McIlroy, <<a href="mailto:doug@cs.dartmouth.edu">doug@cs.dartmouth.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">> The following expressions both cause GHCI to hang:<br>
> <br>
> S.intersection (S.fromList [1,2]) (S.fromList [1..])<br>
> S.intersection (S.fromList [1..]) (S.fromList [1,2])<br>
> <br>
> Is there a smarter way to take the intersection of sets when at least one<br>
> of them is small (but I don't know which one that is)?<br>
<br>
"Small" is not enough. If all you know is that the lists<br>
represent sets of integers, then<br>
<br>
   S.intersection (S.fromList [-1,-2]) (S.fromList [1..])<br>
<br>
must diverge. A sufficient condition for success in such examples<br>
is that the sets come from a well-ordered domain and are presented<br>
in order. Then it's easy to write a merge-like algorithm.<br>
Both sets can be infinite; every finite prefix of the intersection<br>
will eventually appear.<br>
<br>
(Note that the integers are not well-ordered, though the positive<br>
integers are.)<br>
<br>
Doug<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
To (un)subscribe, modify options or view archives go to:<br>
<a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" rel="noreferrer" target="_blank">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br>
Only members subscribed via the mailman list are allowed to post.</blockquote></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sending this from my phone, please excuse any typos!</div></div>