Lesson 18. Folding your way to success
The preceding few lessons covered the main collection types and how to use them. Here we’ll round off with a few scenarios describing how collections can be used in interesting ways to achieve outputs and transformations that you might not think possible through folding. You’ll look at
- Understanding aggregations and accumulation
- Avoiding mutation through fold
- Building rules engines and functional chains
18.1. Understanding aggregations and accumulators
You’re likely already familiar with some of the aggregation functions in LINQ or F# collections, such as Sum, Average, Min, Max, and Count (see figure 18.1). All of these have a common signature: they take in a sequence of elements of type T and return ...
Get Get Programming with F# now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.