Unit 4. Collections in F#
One of the difficulties in designing a book such as this is that many of the language and library features overlap with one another, and it’s often hard to focus on one specific aspect without introducing others into the mix as well. When I originally planned this book, I envisaged discussing collections a little later—but after thinking about it, I decided to bring it forward.
The reason is that collections in F# are fantastic! Combined with the succinct syntax you’ve already seen, and the possibility of a REPL-based environment, F# allows you to start working with data in all sorts of ways that you might not have considered before. (You’ll revisit this in unit 7.)
Part of this unit covers the basic ideas of functional collections, something that, if you’ve ever used LINQ before, will be quite familiar to you. This part will get you up to speed with the typical, most commonly used collection functions. The latter half of the unit focuses on slightly more advanced tips and tricks; for example, how to use functional collections to work with immutable data to simulate imperative loops and mutation.