The List module provides explicit F# functions for processing immutable lists. Instead of dotting into a collection, call operations such as List.map, List.filter, and List.countBy through the module. Learning to read their signatures helps you combine collection functions deliberately rather than guessing at combinations. section 7.2.3
mapping : ('T -> 'U) -> 'T list -> 'U list
Read List.map as a function that takes a transformation from 'T to 'U, then a 'T list, and returns a 'U list. section 7.2.3
Mapping values
A pipeline can transform every list item without a loop or in-place update: let output = [ 1; 2; 3; 4 ] |> List.map (fun x -> x.ToString()). section 7.2.3
Common List module operations include:
- map transforms every item; collect flattens lists of lists. section 7.2.4
- filter selects items, while skip and take select fixed portions. section 7.2.4
- sort orders items; groupBy groups them using a calculated key; windowed provides sliding windows; partition creates two lists from a predicate. section 7.2.4
Practice turns these functions into a reusable vocabulary. A soccer-data exercise combines collect, groupBy, map, and maxBy to find the team with the most goals. Reconsider designs that require while loops, mutable data, in-place updates, or several operations entangled together. section 7.2.4
