Thread overview
slidingSplitter + retro
Oct 06, 2014
Nordlöw
Oct 06, 2014
monarch_dodra
Oct 06, 2014
Nordlöw
Oct 06, 2014
Nordlöw
Oct 06, 2014
Nordlöw
Oct 06, 2014
Nordlöw
October 06, 2014
I've almost satisfied with my new range slidingSplitter at

https://github.com/nordlow/justd/blob/master/range_ex.d#L19

All unittest work as expected except my radial test

https://github.com/nordlow/justd/blob/master/range_ex.d#L243

which, I believe, incorrectly prints

Tuple!(int[], int[])([1, 2], [3])
Tuple!(int[], int[])([1, 2], [3])
Tuple!(int[], int[])([1], [2, 3])
Tuple!(int[], int[])([1, 2, 3], [])
Tuple!(int[], int[])([], [1, 2, 3])

I cannot understand why the line

Tuple!(int[], int[])([1, 2], [3])

is printed twice at the beginning.

Have I done something wrong in my implementation of opIndex or opSlice?
October 06, 2014
On Monday, 6 October 2014 at 20:06:41 UTC, Nordlöw wrote:
> I've almost satisfied with my new range slidingSplitter at
>
> https://github.com/nordlow/justd/blob/master/range_ex.d#L19
>
> All unittest work as expected except my radial test
>
> https://github.com/nordlow/justd/blob/master/range_ex.d#L243
>
> which, I believe, incorrectly prints
>
> Tuple!(int[], int[])([1, 2], [3])
> Tuple!(int[], int[])([1, 2], [3])
> Tuple!(int[], int[])([1], [2, 3])
> Tuple!(int[], int[])([1, 2, 3], [])
> Tuple!(int[], int[])([], [1, 2, 3])
>
> I cannot understand why the line
>
> Tuple!(int[], int[])([1, 2], [3])
>
> is printed twice at the beginning.
>
> Have I done something wrong in my implementation of opIndex or opSlice?

I don't have time to investigate tonight, and it's probably not it, but your "save" isn't saving "_upper".

I don't know how your "radial" works. Does the first "back" print "([1, 2, 3], [])" as it should?
October 06, 2014
On Monday, 6 October 2014 at 21:15:10 UTC, monarch_dodra wrote:
> I don't have time to investigate tonight, and it's probably not it, but your "save" isn't saving "_upper".
>
> I don't know how your "radial" works. Does the first "back" print "([1, 2, 3], [])" as it should?

I've added some extra asserts in the last hour.

I believe the problem remaining now lies in the definition of opSlice.

I'm currently trying to figure out how it should be defined.

Just uncomment line 263 and 264 and run it.

Thanks anyway, for now!
October 06, 2014
On Monday, 6 October 2014 at 21:15:10 UTC, monarch_dodra wrote:
> I don't have time to investigate tonight, and it's probably not it, but your "save" isn't saving "_upper".

No, that wasn't the current problem.

Thanks for catching it anyway.
October 06, 2014
On Monday, 6 October 2014 at 21:15:10 UTC, monarch_dodra wrote:
> I don't know how your "radial" works. Does the first "back" print "([1, 2, 3], [])" as it should?

I nailed it!

The problem was the definition of opSlice.

I had to add an extra internal state

    lower == upper + 1

to represent SlidingSplitter emptyness.

You're welcome to review again now if you feel like :)

https://github.com/nordlow/justd/blob/master/range_ex.d#L18
October 06, 2014
On Monday, 6 October 2014 at 22:11:50 UTC, Nordlöw wrote:
> https://github.com/nordlow/justd/blob/master/range_ex.d#L18

One more thing: I'm unsure how the indexes lower and upper should be treated for narrow strings. Should an index represent a code point or a code unit? I'm not sure. In either way I would really like this range to just work for narrow strings. What do you say monarch_dodra? What's standard D-style way of handling this?