Usage considerations for sequences

As seen earlier, sequences help solve problems in a functional manner by helping you avoid imperative constructs such as iterations and accumulators. However, sequences shouldn't be treated like silver bullets and must be used with good judgement, balancing performance and scalability. Recurring evaluation is a performance concern in sequences; even though on-demand evaluation is one of the powerful aspects of sequences, it may become a performance nightmare if you evaluate all the elements more than once. Depending on the sequence expression, you may end up paying a performance price for evaluating each element many times. In case you need to pre-calculate all the elements ahead of time, you can opt to use a ...

Get Learning F# Functional Data Structures and Algorithms now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.