Monoids and their efficiency in practice

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 →

Share Button

Cartesian product of lists

One of the patterns of problem solving in programming is the Exhaustive Search. This is simply saying that to find a solution to a specific problem, you have to search all the possible solutions and validate them based on some… Continue Reading →

Share Button

An exercise in equational reasoning

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 →

Share Button

Test if a string is a palindrome – a functional programming approach in Haskell

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 →

Share Button

Functional programming – how to naturally construct basic functions. Part 1 – “until” function

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 →

Share Button

A little bit of recursion – the map function

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 →

Share Button

Towards general techniques in programming – the second diagonal principle

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 →

Share Button

© 2017 — Powered by WordPress

Theme by Anders NorenUp ↑