<div class="gmail_quote">On Sun, Sep 5, 2010 at 15:56, Andrei Alexandrescu <span dir="ltr">&lt;<a href="mailto:SeeWebsiteForEmail@erdani.org">SeeWebsiteForEmail@erdani.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
equivalent to the problem:<br>
<br>
auto solution = comp!(&quot;[a,b]&quot;, &quot;a*b == 8&quot;)([1,2,3], [4,5,6]);<br>
<br>
solution is a range, in this case a one element range, containing only<br>
[2,4].<br>
</div></blockquote>I did a range comprehension maybe one year ago, which would be partially<br>
<br>
Here we need to have a crossProduct range, as we discussed in the thread &quot;Combining infinite ranges&quot;. Then it&#39;s easy to combine it with filter:<br>
<br>
auto solutions = filter!&quot;a*b == 8&quot;(crossProduct([1,2,3], [4,5,6]));<font color="#888888"></font></blockquote><div><br>Not exactly: crossProduct is a range, and the only element type that makes sense is Tuple!(A,B).<br>
Unless of course you&#39;re interested in adding binary predicates to filter, which would be understood as automatically opening tuples (and of course, would statically check the length of the tuple and the arity of the passed function). I can add this to Phobos.<br>
<br>What you call crossProduct can be seen as zipWith!tuple(range, range2), which<br><br>If there is interest in this, I also suggest having a n-range version of map that takes a n-ary function and maps them in parallel. <br>
<br>auto m = map!&quot;a &lt; b ? a : c&quot;(range1, range2, range3);<br><br>OK, I definitely need to take some time to assemble all this and propose it for a formal Phobos review. I&#39;ll bump it up higher in my TODO list.<br>
<br>Philippe<br><br><br>Philippe<br></div></div>