std.algorithm's remove

maarten van damme maartenvd1994 at gmail.com
Sat Aug 24 19:24:15 PDT 2013


hello,

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)

My rough version is posted here : http://dpaste.dzfl.pl/4b5a6578

if you look at the output, you'll see this particular line :
"omkom -> komkom because of : kom momkom momkom -> momkomm"

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.
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?)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20130825/3790c688/attachment.html>


More information about the Digitalmars-d-learn mailing list