On Sunday, 23 June 2013 at 04:08:22 UTC, Vladimir Panteleev wrote:
On Saturday, 22 June 2013 at 20:09:01 UTC, monarch_dodra wrote:
#2: Extremelly bad compatibility with simple no bidir/non-slicing ranges: There is no way to iterate over a specific part of a range, and making a range out of what was just iterated over. For example "Get the beggining of this range until the first x": not possible without slicing.

Not sure if I understood the question correctly, but the way I understood it:

1) To iterate over a specific part of a non-random-access range, you can use `drop` in conjunction with `take` or `takeExactly`.

2) To get an existing foreach loop to emit a range, move its body to the predicate of `map`, and break conditions to the predicate of `until` / `countUntil`.

3) As I understand, "get the beggining of this range until the first x, without slicing" is what `until` (or `countUntil` + `take`) does.

All of these will *iterate* over part of said range, but none will actually return the subrange I iterated on.

        V
[ .  .  X  .  .  .  .  .  .  .  . ]

I want:
[ .  .  X ]

D gives me:
      [ X  .  .  .  .  .  .  .  . ]

countUntil + take can kind of mitigate the problem, but that warps the type system: The type of take is not the type of the range.

Reply via email to