A collection groups multiple data items so they can be traversed, transformed, and processed together. Typical application data includes orders, customers, baskets, database results, web-service responses, and event streams. section 7.0 section 10.1
F# provides List, Array, Seq, Set, Map, and Dictionary. F#-specific collections are generally immutable and expose modules with collection-focused functions, while .NET collections support interoperability with C# code. Seq additionally supports lazy evaluation. section 7.3 section 7.6
Common collection-processing patterns include:
- Compose higher-order functions such as transformations into declarative pipelines that are reusable and easy to inspect incrementally in scripts. section 7.6
- Use fold when an operation must collapse several values into one, supplying an input collection, an accumulator, and a starting value. section 7.4 section 7.6
- Prefer tryFind and tryPick when a search may fail; they return options instead of risking runtime exceptions. section 9.1.6
- Use choose when applying a function that may return an option, safely removing None values and unwrapping Some values. section 9.1.6
Aggregating collection data
A customer list can be processed to total outstanding debt, and a basket can be reduced to its checkout price. Both tasks consume many values and return one value; they can be expressed with an imperative loop or a functional fold. section 7.4
Shows how aggregation combines a collection of values into one result. section 7.4















