How to apply a function to every element in a list using Linq in C# like the method reduce() in python? -
how apply function every element in list using linq in c# method reduce() in python?
assuming you're talking this reduce function, equivalent in c# , linq enumerable.aggregate.
quick example:
var list = enumerable.range(5, 3); // [5, 6, 7] console.writeline("aggregation: {0}", list.aggregate((a, b) => (a + b))); // result "aggregation: 18"
Comments
Post a Comment