It was adequate for the first function, but I never knew why you've changed "== bool" to ": bool", and why you're using slices in the second templated function. Philippe explained it in more detail so I'm starting to get it. <br>
<br>Otherwise, the only issue left is the float vs double comparisons. <br><br>For this unittest:<br> double[] d1 = [6.0, 1.5, 2.4, 3];<br> float[] d2 = [1.5, 2.4];<br> assert(find(d1, d2) == d1[1 .. $]);<br><br>
Inside the second template function I've added a writeln, and I can see the if statement evaluates "[1.5, 2.4] == [1.5, 2.4]" to false and will not break out of the loop. I don't know whether this is a DMD bug or if "float[] d2" should be changed to "double[] d2" in TDPL, since that runs fine. IIRC arrays are value types and as such they are compared bit-by-bit to each other, right? And since doubles and floats have different sizes, that unittest then fails. <br>
<br><br><div class="gmail_quote">On Wed, Jul 28, 2010 at 6:19 PM, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org">SeeWebsiteForEmail@erdani.org</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;">
<div class="im">Andrej Mitrovic wrote:<br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
Also, Andrei, you never explained the if(is()) signature of the second templated function. I hope to get some pointers on that. :)<br>
</blockquote>
<br></div>
Is the explanation on page 141 adequate?<br><font color="#888888">
<br>
Andrei<br>
</font></blockquote></div><br>