Tag Archives: data structures

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


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

F#: A Data Structure For Modelling Directional Graphs

In my previous post, I described how to parse a regular expression pattern into an abstract syntax representation.  The next phase is to transform the parsed syntax into a finite state machine.  I have chosen to model the FSM as a mathematical directional graph (digraph).  This post describes the implementation of this module in preparation for the actual compilation step.

You can read the previous article here: F#: Building a Regular Expression Pattern Parser.

Continue reading