<div dir="ltr">hello,<div><br></div><div>I'm a hobyist-programmer and around where I live there's a group of haskell fanatics. They posted solutions to a recent programming challenge which I find to be a bit ugly. For fun I wanted to implement it in d and a rough version (not correct yet, this was written/hacked in 5 minutes after reading the exercise)</div>
<div><br></div><div>My rough version is posted here : <a href="http://dpaste.dzfl.pl/4b5a6578">http://dpaste.dzfl.pl/4b5a6578</a><br><br>if you look at the output, you'll see this particular line : </div><div><span style="color:rgb(51,51,51);font-family:monospace;font-size:11px;line-height:18px;white-space:pre-wrap;background-color:rgb(245,245,245)">"omkom -> komkom
because of : kom
momkom
momkom -> momkomm"</span><br></div><div><br></div><div><font color="#333333" face="monospace"><span style="font-size:11px;line-height:18px;white-space:pre-wrap">This is because of what remove from std.algorithm does. It not only returns a range with that element removed (as the name implies), it also modifies the original range.</span></font></div>
<div><font color="#333333" face="monospace"><span style="font-size:11px;line-height:18px;white-space:pre-wrap">I assume this decision was made for efficiency purposes but that is one of the most ugliest things I have ever come across. At least c# forces the 'ref' in it's parameters so you know something's up. Is there any way I could've known this? (apart from reading the documentation on every single trivial function in the std library?)</span></font></div>
</div>