Maybe I'm missing something, but I can't think of anyway *at all* to do this generically.

Lets say I have some arbitrary bidirectional range, R, and I want to find the first element that satisfies some predicate. After that, I want to reverse the part of the range up to that element.

Essentially, I'd like to do something along the lines of:

  reverse(until!(pred)(R));

but Until is (correctly) not bidirectional, so I can't do that.

Use indexing and slicing is not an option because the range isn't necessary random-access.

This isn't about what std.algorithm and std.range can do -- I can't even think of a way to do this using primitive range operations.

Also note that popping off from the back of the range is not an option either because the range could be arbitrarily long and the predicate is usually satisfied very early in the range.

Thanks in advance.

Reply via email to