F# Operations on List

In this post I want to show how you can implement common list operations: union, intersection, difference and concatenation. Concatenation is the simplest of them all, because type List already has a function call append that does everything for you. let concat left right = List.append left right The union of two lists is a … Read more

Parsing ranges with FParsec

FParsec is an F# adaptation of Parsec, a free monadic parser combinator library for Haskell. It can parse context-sensitive, infinite look-ahead grammars, has complete support for unicode input and large files (> 4 GB) and produces excellent error messages. You can download and install it from the above link. To use it in an application, … Read more

Even numbers as sum of 2 primes

A very old unsolved problem in numbers theory, known as Goldbach’s conjecture, says that any even number greater than 5 can be written as the sum of 2 prime numbers. It hasn’t been solver yet, not I will try to solve it. But I decided to write some F# code to display all the possibilities … Read more

Word Reducing Puzzle

I recently found an interesting problem on the web, about reducing words, letter by letter until only one letter remains. Here is a formal definition: We define word reduction as removing a single letter from a word while leaving the remaining letters in their original order so that the resulting sequence of characters is also … Read more

Game of Life in F#

The Game of Life is a cellular automaton devised by the John Horton Conway in 1970. It is the best-known example of a cellular automaton. It consists of a collection of cells which, based on a few mathematical rules, can live, die or multiply. Depending on the initial conditions, the cells form various patterns throughout … Read more

Parallelization in F#

In my last post I was writing about parallelizing loops with Parallel.For in C#. Today I though it would be nice to try that in F#. So, here is the benchmarking of the matrix multiplication and the bubblesort algorithm in F4. Matrices Multiplication I started with a create_matrix function that creates and randomly initializes a … Read more

F# Resources

Here is a list of, what I consider, good F# resources. Hopefully you’ll find them helpful. Official Documentation Official F# page at Microsoft Research F# manual informal F# documentation Forums and Wikis F# wikicontains articles, tips and sample code hubFSa very good forum focused on F# Blogs Don Syme’s Blog: the blog of F#’s creator … Read more