Tag Archives: sequence comprehensions

F#: Nested Data Structures, Enumeration and Sequence Comprehensions

I have been working on a business data model for my WPF demo application (which I hope to begin describing soon). One of my requirements for this was a nested data structure to model a namespace hierarchy. Doing this in an imperative way was easy but my goal was to use immutable data structures to support a functional-programming approach to the data. Eventually, I settled on a nested Map structure with an F# record data type to represent the underlying data. Structurally, this was similar to how I would have approached it from an imperative perspective, but this was after several other attempts using custom data structures (abstract syntax trees and other approaches) had proven too inflexible to the demands of the application.

A second requirement for this data structure was abstraction. I did not want the internal data structure to be exposed to client code. Therefore, I needed to provide custom enumeration support. This post describes two approaches to this.

Continue reading

Advertisements

F#: Sequence Comprehensions and Iteration

This is a quick post about sequence comprehensions in F#, and also a quick introduction to a few of the standard collection types.  I hit some issues while developing the regular expression engine (see my previous and upcoming posts!) and this post describes the issues and the solution.

Continue reading