Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
F# 4.0 Design Patterns

You're reading from   F# 4.0 Design Patterns Solve complex problems with functional thinking

Arrow left icon
Product type Paperback
Published in Nov 2016
Publisher Packt
ISBN-13 9781785884726
Length 318 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Gene Belitski Gene Belitski
Author Profile Icon Gene Belitski
Gene Belitski
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Begin Thinking Functionally 2. Dissecting F# Origins and Design FREE CHAPTER 3. Basic Functions 4. Basic Pattern Matching 5. Algebraic Data Types 6. Sequences - The Core of Data Processing Patterns 7. Advanced Techniques: Functions Revisited 8. Data Crunching – Data Transformation Patterns 9. More Data Crunching 10. Type Augmentation and Generic Computations 11. F# Expert Techniques 12. F# and OOP Principles/Design Patterns 13. Troubleshooting Functional Code

Lazy over eager data collections

Let me turn your attention to the comparison of memory consumption of the previously mentioned object-oriented and functional solutions. The object-oriented solution eagerly creates, materializes in computer memory the collection of 996 OfDigits objects; that is, its memory consumption is a linear function of the problem dimensions. In contrast to this approach, the functional solution does not require more than a single instance of OfDigits at any moment of the max aggregation, lazily producing the same 996 objects one by one according to the demand of the max aggregator function, hence having memory consumption that is constant and (almost) independent of the problem dimensions. This is a rather complex quality. If you imagine that the initial condition has suddenly changed and hugeNumber is really huge, then the object-oriented solution may become non-applicable due to the lack of required memory, while the functional solution, being agnostic to this factor, will continue to work. Generalizing this observation, the functional paradigm allows you to solve problems of a bigger scale, rather than taking other approaches by utilizing the lazy manner of data manipulation. The interesting corollary stemming from this approach is the technique of manipulating data sequences of unlimited length that do not require their complete materialization in the memory.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime