Slide - what does withPartial do?

Simen Kjærås simen.kjaras at gmail.com
Thu Mar 1 09:27:31 UTC 2018


On Thursday, 1 March 2018 at 08:31:05 UTC, Piotr Mitana wrote:
> For some reason this is true:
>
> slide!(Yes.withPartial)([1, 2, 3, 4, 5], 3).array == [[1, 2, 
> 3], [2, 3, 4], [3, 4, 5]]
>
> Shouldn't it rather return [[1], [1, 2], [1, 2, 3], [2, 3, 4], 
> [3, 4, 5], [4, 5], [5]], or at least [[1, 2, 3], [2, 3, 4], [3, 
> 4, 5], [4, 5], [5]]?
>
> I can see no difference on the result when withPartial is on 
> and off.
>
> Is it a bug or I don't understand it correctly?

It seems it should only do anything when the window size is 
larger than the range being iterated over. So something like 
slide!(Yes.withPartial)([0,1,2], 4).array = [[0,1,2]].

--
   Simen


More information about the Digitalmars-d-learn mailing list