using System.Text; namespace Lab10EN; public static class EnumerableExtensions { public static TAccumulate Collect( this IEnumerable source, TAccumulate collection, Action accumulator) { foreach (var element in source) { accumulator(collection, element); } return collection; } public static IEnumerable Filter(this IEnumerable source, Predicate predicate) { foreach (var t in source) { if (predicate(t)) yield return t; } } public static string ConcatStrings(this IEnumerable source) { return source.Filter(t => t is string) .Collect( new StringBuilder(), (sb, str) => sb.Append(str)) .ToString(); } }