Lesson 16. Useful collection functions
Now that you have a reasonably high-level understanding of collections in F#, this lesson focuses on getting your muscle memory trained to use collections in practical situations. This lesson covers the following:
- The most common collection functions across the three types that you’ve learned about (Seq, List, and Array) with some visualizations and hands-on examples
- A comparison of F# functions with similar LINQ operations
- The differences between imperative and declarative solutions
- Moving between collection types
Each operation we cover has a simple example associated with it, alongside typical use cases and equivalents in both imperative coding and LINQ (if it exists). Go through every example in a script yourself rather than simply reading them; you’ll learn these effectively only through practical experience. After that, I’ll also point out some other related functions in the collection libraries (denoted by see also) that you should look at in your own time.
A quick note: as in LINQ, most of the methods in F# collections operate on empty collections without a problem; you’ll get back an empty collection again.