std.algorithm.splitter on a string not always bidirectional
H. S. Teoh
hsteoh at quickfur.ath.cx
Fri Jan 22 19:56:37 UTC 2021
On Friday, 22 January 2021 at 17:29:08 UTC, Steven Schveighoffer
wrote:
> On 1/22/21 11:57 AM, Jon Degenhardt wrote:
[...]
>> Another way to look at it: If split (eager) took a predicate,
>> that 'xyz.splitter(args).back' and 'xyz.split(args).back'
>> should produce the same result. But they will not with the
>> example given.
>
> With what example given? The example you gave is incomplete
> (what are args?)
[...]
Here is a case for which iterating forwards yields a different
sequence
from iterating backwards (if we were to allow the latter):
"bbcbcba".splitter("bcb")
Iterating forwards gives us the subranges: "b", "cba".
Iterating backwards gives us: "a", "bbc".
So it cannot be a bidirectional range, at least not in the
expected sense
that iterating from the back ought to give us the same subranges
as
iterating from the front, only in a reverse order. Here iterating
backwards yields a completely different decomposition.
--T
More information about the Digitalmars-d-learn
mailing list