public static IEnumerable<IList<TSource>> WindowLeft<TSource>(
this IEnumerable<TSource> source,
int size
)
<ExtensionAttribute>
Public Shared Function WindowLeft(Of TSource) (
source As IEnumerable(Of TSource),
size As Integer
) As IEnumerable(Of IList(Of TSource))
public:
[ExtensionAttribute]
generic<typename TSource>
static IEnumerable<IList<TSource>^>^ WindowLeft(
IEnumerable<TSource>^ source,
int size
)
[<ExtensionAttribute>]
static member WindowLeft :
source : IEnumerable<'TSource> *
size : int -> IEnumerable<IList<'TSource>>
A window can contain fewer elements than size, especially as it slides over the end of the sequence.
This operator uses deferred execution and streams its results.
Console.WriteLine(
Enumerable
.Range(1, 5)
.WindowLeft(3)
.Select(w => "AVG(" + w.ToDelimitedString(",") + ") = " + w.Average())
.ToDelimitedString(Environment.NewLine));
// Output:
// AVG(1,2,3) = 2
// AVG(2,3,4) = 3
// AVG(3,4,5) = 4
// AVG(4,5) = 4.5
// AVG(5) = 5