I am forking this issue out of #627 as the discussion on WindowLeftAndRight was diverging from the subject of #627. Below is the quoted discussion thus far.
@Orace said:
@atifaziz is there any equivalent to WindowLeftAndRight available ?
@atifaziz said:
is there any equivalent to WindowLeftAndRight available ?
No, never needed it and no one ever asked for it. Do you have a use case?
@Orace said:
I was looking for it to improve it ;)
I think a Window(int size, bool extendLeft = false, bool extendRight = false, bool extendBoth = false) overload is missing here.
The behavior will be
extendLeft |= extendBoth;
extendRight |= extendBoth;
The usages pretty straightforward.
@atifaziz said:
For dynamic behaviour? I think if someone needs that, they can achieve it like this:
var xs = Enumerable.Range(1, 5);
var windows =
from f in new Func<IEnumerable<int>, int, IEnumerable<IList<int>>>[]
{
MoreEnumerable.Window,
MoreEnumerable.WindowLeft,
MoreEnumerable.WindowRight,
}
select f(xs, 3).Select(w => $"[{w.ToDelimitedString(", ")}]")
.ToDelimitedString(", ");
foreach (var ws in windows)
Console.WriteLine(ws);
// output:
// [1, 2, 3], [2, 3, 4], [3, 4, 5]
// [1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5], [5]
// [1], [1, 2], [1, 2, 3], [2, 3, 4], [3, 4, 5]
@Orace said:
My proposal is Window(size, extendLeft: true) as an alias for WindowLeft(size), same thing for right. + we have a free WindowLeftAndRight. And all of this can fit in a single implementation.
It facilitate the cases where the choice is made at runtime: Window(size, extendRight: isTailNeed)
We have to discuss the name of the optional extendLeft, extendRight, extendBoth parameters.
I am forking this issue out of #627 as the discussion on
WindowLeftAndRightwas diverging from the subject of #627. Below is the quoted discussion thus far.@Orace said:
@atifaziz said:
@Orace said:
@atifaziz said:
For dynamic behaviour? I think if someone needs that, they can achieve it like this:
@Orace said: