Skip to content

Category Archives: Uncategorized

Pattern matching F# Lists

Here are some simple examples I’ve come up with for working with lists in F#. These follow on from previous work looking at finding a value in a list and again this is definitely not efficient F# code. I’m just playing around in the language and trying to understand things.

First I tried walking a [...]

Matching patterns in F#

Patterns in F# are kind of like switch statements in C#, but much more powerful. For my first experiment with them I decided to see if I could find a word in a sentence. This is definitely the wrong way to go about solving this problem, calling String.Contains() would be easier. But I am still [...]

Initialization In F and C #

There are some common compiler tricks in F# and C#, for example object initialization.

In C# 3.0 we have Object Initializers which allow for an object to be instantiated via an explicit constructor call and properties to be set in one statement.

Form f = new Form1() { Text = “Hello” }; Application.Run(f);

And in F# we [...]

Inferred Generics in F#

The first hundred or so pages of Expert F# have been really interesting, the compiler feels so much more advanced than C#. Although I think it has more to do with the nature of functional programming than any deficiency in the C# compiler. The code does not tell the machine how to do something rather [...]

Persisting Computed XML

It’s possible to define an XML column as a computed column. And in most cases I think it would make sense to persist the column to save doing all that work again. As Bob Beauchemin points out there’s a trick to doing it.

The first thing you need is a user defined scalar function to [...]