On 1/15/13 2:20 AM, monarch_dodra wrote:
On Tuesday, 15 January 2013 at 05:51:16 UTC, Andrei Alexandrescu wrote:
R rfind(R, E)(R range, E element)
{
for (;;)
{
auto ahead = range.save.find(element);
if (ahead.empty) return range;
range = ahead;
}
}

I'd hardly call that an ideal solution >:( The point of rfind is to not
start the search from the start of the string.

I may reply to the rest, but let me destroy this quickly: this is the implementation for a forward range that's not bidirectional. The challenge is indeed implementing rfind for bidirectional ranges that are not random (e.g. strings).


Andrei

Reply via email to