<br><br><div class="gmail_quote">On Thu, Sep 2, 2010 at 09:06, Peter Alexander <span dir="ltr"><<a href="http://peter.alexander.au">peter.alexander.au</a>@<a href="http://gmail.com">gmail.com</a>></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;">
On 2/09/10 7:34 AM, Pelle wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
It needs opEquals :-)<br>
</blockquote>
<br>
Yeah, it needs a lot of things :)<br>
<br>
You could easily add unary operators as well (e.g. so that -amb([1, 2]) == [-1, -2]. I didn't bother adding more than I did because it would make the post too large, and wouldn't really add anything (I thought that the binary ops + dispatch covered most of the interesting cases).<br>
<br>
Also, I think it would supposed to return amb(map!...) instead of just returning map!... (otherwise you couldn't chain them), but that's a simple fix.<br></blockquote><div><br>Yes, like Haskell monads: get into, transform, return a wrapped result.<br>
</div></div><br>Does your code compile for you? I tried it when you posted it on SO and the .length, .replace("a","u") didn't work.<br>I had to change opDispatch from<br><br> auto opDispatch(string f)()<br>
{<br> mixin("return map!((E e) { return e."~f~"; })(r);");<br> }<br><br>to:<br><br> auto opDispatch(string f)()<br> {<br> return map!(unaryFun!("a."~f))(r);<br> }<br>
<br>I tried to do the same for the dispatch with arguments, but got very strange errors. DMD told me it couldn't get the args at CT.<br><br>Oh, but you changed your code on SO. It can know do the first example too. That's good, and was in fact my main subject of interest. Amb seems to be like the product of two ranges (with an operator), which is then flattened.<br>
<br>What I don't get is the link with the ruby article and its use of if.<br><br><br>Philippe<br><br>