How to make rsplit (like in Python) in D without need for extra allocation using standard library? And why there is no algorithms (or parameter in existing algorithms) to process range from the back. Is `back` and `popBack` somehow worse than `front` and `popFront`.

I've tried to write somethig that would work without allocation, but failed.
I have searching in forum. Found this thread:
https://forum.dlang.org/post/bug-1030...@http.d.puremagic.com%2Fissues%2F

I tried to use `findSplitBefore` with `retro`, but it doesn't compile:

import std.stdio;
import std.algorithm;
import std.range;
import std.string;

void main()
{
        string str = "Human.Engineer.Programmer.DProgrammer";
        
        writeln( findSplitBefore(retro(str), ".")[0].retro );
}

Compilation output:
/d153/f534.d(10): Error: template std.range.retro cannot deduce function from argument types !()(Result), candidates are: /opt/compilers/dmd2/include/std/range/package.d(198): std.range.retro(Range)(Range r) if (isBidirectionalRange!(Unqual!Range))


Why I have to write such strange things to do enough wide-spread operation. I using Python at the job and there is very much cases when I use rsplit. So it's very strange to me that D library has a lot of `advanced` algorithms that are not very commonly used, but there is no rsplit.

Maybe I missing something, so please give me some advice)

Reply via email to