David Raab · Blogging about programming

Understanding Fold

comments
A very important function in List-processing is the List.fold function. List.fold is a very powerful function that gives you a lot of flexibility to do any kind of list transformation. The disadvantage is that this kind of power makes understanding List.fold a lot harder. In this article we look at...

Continue reading ...

Variable Arguments in F#

comments
One question that appears in F# from time to time is: How do you create a function that expects a variable amount of arguments? A short answer is: You can't do that. A longer and correct answer: You can do it with (static) methods. But you probably don't want to...

Continue reading ...

Mutability vs. Immutability: Valid objects

comments
I already wrote an article that explains immutability, but one thing I hand-waved was the benefits of immutability and why you should program with immutable values. In this article I talk about those benefits by trying to maintaining valid objects at all time and show how we can achieve it...

Continue reading ...

Function Application and Composition

comments
Function application is probably one of those terms in functional programming that sounds more scarier as the topic really is. The idea behind functional application just means that we execute a function to get the result. Let's take the example of calculating the square root of 2.0. We can write...

Continue reading ...

Catamorphisms

comments
Up to this point I created various articles about fold, in my Series I also created a category named Fold (Catamorphisms) but up till now I didn't explained how this articles related to each other, or what Catamorphisms mean. In this article I want to talk about the remaining parts....

Continue reading ...

Monoids

comments
A monoid is a simple concept. It is a generalization of some patterns that you very likely already have seen. Being aware of those can help in designing some operations, and can simplify things. Without much further ado, let us look at three simple math equations. 1: 2: 3: 1...

Continue reading ...

Introduction to Functional Programming

comments
In this article I want to give a general introduction to some of the fundamental ideas of functional programming. I just start with the idea of function as data, and explain why functions are viewed as data and why it makes sense to pass functions as arguments. When we understand...

Continue reading ...

The Option Module

comments
The Option type is a well known and often used type, but at least for me, most of the time I just used Option.map and Option.bind and ignored functions like Option.exists, Option.filter, Option.fold and so on. I spent some time with those functions to understand when those are useful. defaultArg...

Continue reading ...

CPS fold -- fold with early exit

comments
The most general function to traverse a data-structures is the fold function. But fold has one problem that is sometimes not optimal. It always traverses the whole data-structure and we cannot abort the recusion early. But sometimes, that is exactly what we want to do. For example when we want...

Continue reading ...

Algebraic Data-Types

comments
When we work in a programming language we usually have some primitive data-types likes int, float, string, bool and so on. All of those are important, but when we need to create more advanced logic we usually want to create our own data-types and group/compose different types together to create...

Continue reading ...