On 06/08/2010 08:31 AM, Alex Makhotin wrote:
Bernard Helyer wrote:This worked. Until I turned unittests on, and the assert I showed above tripped. At this point my language turned rather unpleasant and I wrote this: bool contains(T)(const(T)[] l, T a) { foreach(e; l) { if (a == e) { return true; } } return false; } And my problems went away. I assume what I experienced is a bug, but I'm not sure, so I thought I'd share my experience.I want you to know that you are not the only one who makes such decisions. I have almost the same method, except it returns an index value. That is not the only one reason I wanted a std library with clear and documented interfaces. Generally I use std library to make writeln, thread wrapper around OS, and string conversions. I do not want to use std.algorithm.
If you could frame that as a requirement, I'd be glad to look into improving std.algorithm. (BTW. std.algorithm has had indexOf for a while, I haven't checked in that yet.)
Andrei
