<div dir="ltr"><div><div><div>Thanks for all your help understanding the algorithm chaining problem...<br><br></div>Now I have another gotcha.<br><br></div>This code compiles and runs OK if I remove the keyword "pure" or if I remove the ".retro"<br>
<br></div><div>As I understand it retro should affect the "pure"ness of the the function.<br></div><div><br></div>If I put the keyword in, it fails to instantiate the template...<br>import std.algorithm;<br>import std.array;<br>
import std.stdio;<br>import std.range;<br><br>pure auto huh( in uint[] digitArray, in uint value)<br>{<br> return find!( (a,b) => (a > b))( digitArray.retro, value);<br>}<br><br>unittest {<br> auto test = [11u, 1u, 1u, 10u];<br>
auto s = huh( test, 10u);<br> writeln( s);<br>}<br><br>dmd -unittest -main doesnt_work.d && ./doesnt_work<br>/usr/include/dmd/phobos/std/algorithm.d(3508): Error: pure function 'doesnt_work.huh' cannot call impure function 'std.range.retro!(const(uint)[]).retro.Result.popFront'<br>
/usr/include/dmd/phobos/std/algorithm.d(3510): Error: pure function 'doesnt_work.huh' cannot call impure function 'std.range.retro!(const(uint)[]).retro.Result.front'<br>doesnt_work.d(8): Error: template instance doesnt_work.huh.find!(__lambda3, Result, const(uint)) error instantiating<br>
<br><div><div><div><div>-- <br><div dir="ltr">John Carter<br>Phone : (64)(3) 358 6639<br>Tait Electronics <br>PO Box 1645 Christchurch<br>New Zealand<br><br></div>
</div></div></div></div></div>
<br>
<hr><font color="#808080">This email, including any attachments, is only
for the intended recipient. It is subject to copyright, is confidential
and may be the subject of legal or other privilege, none of which is
waived or lost by reason of this transmission.</font><div><font color="#808080">If
you are not an intended recipient, you may not use, disseminate,
distribute or reproduce such email, any attachments, or any part
thereof. If you have received a message in error, please notify the
sender immediately and erase all copies of the message and any
attachments.</font></div><div><font color="#808080">Unfortunately, we
cannot warrant that the email has not been altered or corrupted during
transmission nor can we guarantee that any email or any attachments are
free from computer viruses or other conditions which may damage or
interfere with recipient data, hardware or software. The recipient
relies upon its own procedures and assumes all risk of use and of
opening any attachments.</font></div><div><hr></div>