From 1ec4204fd29249a3585adb98765b7b8178cdb21d Mon Sep 17 00:00:00 2001 From: Sun Serega Date: Mon, 26 Aug 2024 09:20:27 +0300 Subject: [PATCH] `.Batch` cleanup (#3108) --- bin/Lib/PABCSystem.pas | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/Lib/PABCSystem.pas b/bin/Lib/PABCSystem.pas index f199647cb..402cf81f5 100644 --- a/bin/Lib/PABCSystem.pas +++ b/bin/Lib/PABCSystem.pas @@ -11352,9 +11352,9 @@ begin end; /// Разбивает последовательность на серии длины size -function Batch(Self: sequence of T; size: integer): sequence of sequence of T; extensionmethod; +function Batch(Self: sequence of T; size: integer): sequence of array of T; extensionmethod; begin - var buf := new List; + var buf := new List(size); foreach var elm in Self do begin buf.Add(elm); if buf.Count=size then begin @@ -11368,10 +11368,10 @@ begin end; /// Разбивает последовательность на серии длины size и применяет проекцию к каждой серии -function Batch(Self: sequence of T; size: integer; proj: Func, Res>): sequence of Res; extensionmethod; +function Batch(Self: sequence of T; size: integer; proj: Func): sequence of Res; extensionmethod; begin //Result := SeqWhile(Self, v -> v.Skip(size), v -> v.Count > 0).Select(v -> v.Take(size)).Select(ss -> proj(ss)); - Result := Self.Batch(size).Select(ss -> proj(ss)); + Result := Self.Batch(size).Select(proj); end; ///--