From 7bd70fcb311c808b65b62e774755dcbd6b0d63cd Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Fri, 21 Aug 2020 12:58:15 +0300 Subject: Insights anomalies. --- .../Tango.Core/ExtensionMethods/ListExtensions.cs | 26 ++++++++++++++++++++++ .../Visual_Studio/Tango.Core/Tango.Core.csproj | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 Software/Visual_Studio/Tango.Core/ExtensionMethods/ListExtensions.cs (limited to 'Software/Visual_Studio/Tango.Core') diff --git a/Software/Visual_Studio/Tango.Core/ExtensionMethods/ListExtensions.cs b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ListExtensions.cs new file mode 100644 index 000000000..f3e57b3ea --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/ExtensionMethods/ListExtensions.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + + +public static class ListExtensions +{ + /// + /// Splits the list to chunks. + /// + /// + /// The source. + /// Size of the chunk. + /// + public static List> ChunkBy(this List source, int chunkSize) + { + return source + .Select((x, i) => new { Index = i, Value = x }) + .GroupBy(x => x.Index / chunkSize) + .Select(x => x.Select(v => v.Value).ToList()) + .ToList(); + } +} + diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index ef8ab0a30..2db9c8643 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -100,6 +100,7 @@ + @@ -215,7 +216,7 @@ - + -- cgit v1.3.1