Category Archives: Algorithms

Implementing algorithms in a functional style

Digital Signal Processing #1

The following example uses sequence and array operators to implement a simple digital filter. The example builds on the previous WAV I/O example. A digital filter frequently needs multiply-add operators, these may be implemented using Array.map2 > let fx = … Continue reading

Posted in Algorithms, IO | Leave a comment

Efficient Sequence Operators: Seq.breakBy

I wanted to create a sequence function which would break a sequence into a number of equally sized chunks (e.g. to create a sequence of 4 byte arrays out of a byte stream to pass it to System.BitConverter). Here is … Continue reading

Posted in Algorithms, Language | 1 Comment

Interactive Session #11: Units of Measure

F# includes a language feature to annotate your code with units of measure like meter, second or kilogram, preferably from the SI system. These units are statically checked during compile time and will not be part of the compiled code. … Continue reading

Posted in Algorithms, Getting Started, Language | 1 Comment

Interactive Session #8: Pipeline Operator

The pipeline operator |> is a quite unique feature of F#, it allows to connect functions which take one argument together by passing the result of one function to the next. > let add1 x = x+1.0;; val add1 : … Continue reading

Posted in Algorithms, General, Language | Leave a comment

Parallel mandelbrot generator

F# offers very good support for implementing algorithms in a parallel way to exploit multi-core processors. The following example of a mandelbrot generator uses a lot of F# specific features using operator overloading to create a complex type, the async … Continue reading

Posted in Algorithms, Parallel | Leave a comment