Functional Programming

An optimization using the foldr fusion law

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 →

Share Button

Heuristic guidance from equational reasoning

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 →

Share Button

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

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

© 2022 — Powered by WordPress

Theme by Anders NorenUp ↑