Book Image

Learning F# Functional Data Structures and Algorithms

By : Adnan Masood
Book Image

Learning F# Functional Data Structures and Algorithms

By: Adnan Masood

Overview of this book

Table of Contents (21 chapters)
Learning F# Functional Data Structures and Algorithms
Credits
Foreword
Foreword
Foreword
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Diving deep into enumerations and sequences


You may recall that we discussed enumerations and sequences in Chapter 3, What's in the Bag Anyway, where we explain sequences as Schrödinger's lists, that is, a data structure that contains elements that are evaluated on demand. Under the covers, the sequence seq<'T> or 'T seq is just IEnumerable<'T> for a generic type T, which is now a commonly used construct since the introduction of LINQ to the .NET Framework. It won't be incorrect to say that introducing LINQ to .NET was the beginning of functionalization of C#. Many functional features you see in C# nowadays are borrowed from, or have been cross-pollinated during, F# development and subsequent integration with CLR.

In the .NET framework class library, IEnumerable<'T> is defined as an interface that exposes an enumerator to iterate over a collection. An interface provides a relationship to the type, and is basically a collection of attributes and methods. It serves as a contract...