This is the 2nd part of my series on everyday functional programming.
Suppose you have a collection of items and need to grab just a subset that match a certain criteria. Programming C# in an imperative style, you could use a for or foreach loop as follows:
Functional programming recognises this common scenario as a higher order function known as a Filter ; where you want to create a new list for every element that evaluates to true when a predicate function is applied to it.
In C#, filter is implemented as the LINQ Where(Func
Apart from the obvious reduction in number of lines; notice how much clearer the intent of the filter is, and the many opportunities for error we have eliminated.
In C#, map is implemented by the LINQ Select(Func
 – http://railspikes.com/2008/7/29/functional-loops-in-ruby-each-map-inject-select-and-for
 – http://msdn.microsoft.com/en-us/library/system.linq.enumerable.aspx
 – http://en.wikipedia.org/wiki/Filter_(higher-order_function)
 – http://en.wikipedia.org/wiki/Map_(higher-order_function)