### Functional Programming

Because I find this exercise ([1]) very instructive, I want to show you how the foldr fusion law can be used to derive an efficient program from a very inefficient one. This note will let you see some important points:… Continue Reading →

Working through the exercises of Richard Bird (Thinking Functionally with Haskell), I found a particular one that can be used to illustrate how equations can give us heuristic guidance in solving particular functional problems. The same pattern of thought will be… Continue Reading →

As we observed in the post about equational reasoning (An exercie in equational reasoning), constructing algorithms based on laws can help us gain a lot in efficiency. Let’s introduce a little theory first. A monoid is a pair (M,o) where… Continue Reading →

This is an exercise found in the very good book of Richard Bird, Thinking Functionally with Haskell. It is a good example of how a certain method of thinking can help us to reason about programs in functional programming. The method… Continue Reading →

I could write this post by showing directly my solution and why it is efficient, but this is a kind of exposition that implies arrogance. Instead, I want to show you how functional reasoning allows you to write efficient programs…. Continue Reading →

When one meets for the first time functional programming, the first impression is that some higher order functions are too hard to cope with and to understand the basics is a little tricky. In this post I’ll show that is… Continue Reading →

One of the most useful things that you encounter all the time in programming is applying the same principle on every number in a sequence. For example, sometimes we have a list of numbers: [1,2,3] and we want to construct… Continue Reading →

When we work with infinite lists in Haskell, one important problem is: Problem. Construct a list which generates all the distinct ordered pairs of natural numbers. So, we want a method to generate the set: {(0,0), (0,1),(0,2),…, (1,0), (1,1),(1,2),…} etc…. Continue Reading →