The rfind challenge
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jan 15 04:54:12 PST 2013
On 1/15/13 1:31 AM, H. S. Teoh wrote:
> Hmm. What about introducing a new primitive takeUntil, that returns the
> initial segment of the range until a given predicate becomes true? Then
> you could implement rfind thus:
>
> auto rfind(alias pred, R)(R range)
> if (isBidirectionalRange!R)
> {
> return range.retro()
> .takeUntil!pred()
> .retro();
> }
That works, but returns a different type. Ideally rfind would return the
same type as the initial range, R.
Andrei
More information about the Digitalmars-d
mailing list