This chapter was a deep dive into the ubiquitous IEnumerable
, the F# data structure of sequences. Now, you should have a thorough understanding of sequences, the underlying operations, and query expressions. A sequence is a list of potential values computed on demand. Sequences can be created using a range expression, a sequence expression, the seq
keyword, library methods such as init
and initInfinite
from the Seq
module, or simply by treating some IEnumerable
as an F# sequence. The Seq
module has a large number of sequence-related operations available. You can easily implement custom enumeration (paging) in sequences by applying predicate-based filters. Last, but not the least, you should optimize the evaluations in the sequence and use Seq.cache
to avoid repeated evaluation whenever possible.
In the next chapter, we will gain knowledge about a custom ADT, which is outside the F# core library—a stack. You will also be prepared for more advanced implementations, necessary test cases...