<br><br><div class="gmail_quote">On Sun, Sep 5, 2010 at 12:00, Simen kjaeraas <span dir="ltr">&lt;<a href="mailto:simen.kjaras@gmail.com">simen.kjaras@gmail.com</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;">
<div class="im">Philippe Sigaud &lt;<a href="mailto:philippe.sigaud@gmail.com" target="_blank">philippe.sigaud@gmail.com</a>&gt; wrote:<br>
<br>
</div><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">
I guess the D syntax would be<br>
auto x = amb([1,2,3]);<br>
auto y =amb([4,5,6]);<br>
x*y == 8; // forces desambiguation =&gt; the ambs explore the possibilities.<br></div><div class="im">
assert(x == amb([2]));<br>
assert(y == amb([4]));<br>
<br>
There is only one value left, no more ambiguity.<br>
</div></blockquote>
<br>
But what happens in the case where there is more than one value left?<br></blockquote><div><br>If I understand correctly the linked Ruby and Haskell versions, the search stops as soon as you find a possibility. But then, I&#39;m no pro on this.<br>
<br><br> </div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
That&#39;s one of the reasons I feel that doing the combination, then<br>
filtering it, is more correct. There is also the fact that the above<br>
syntax does not let you call arbitrary functions in the requirements,<br>
something filter does.</blockquote><div><br>The combining and filtering is interesting (in this case, it&#39;d be like doing a  list comprehension). <br>But the real challenge in the SO question is the &#39;going back in time&#39; part, which I have trouble to understand : how can you modify x and y through a multiplication and a comparison?<br>
<br>I did a range comprehension maybe one year ago, which would be partially 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 [2,4].<br>
<br><br>Philippe<br><br> </div><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"><br>
<br>
<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Maybe in this case an<br>
&#39;alias possibilities[0] this&#39; could do the trick:<br>
<br>
assert(x == 2);<br>
assert(y == 4);<br>
<br>
Can we do alias someArray[0] this; ?<br>
</blockquote>
<br></div>
Well, we can do this:<br>
<br>
struct foo( R ) {<br>
    R range;<br>
<br>
    ref ElementType!R getFront( ) {<br>
        return range.front;<br>
    }<br>
<br>
    alias getFront this;<br>
}<br>
<br>
-- <br><font color="#888888">
Simen<br>
</font></blockquote></div><br>