Archives for November, 2008
From foldl to difference lists
Sunday, November 9th, 2008
Most declarative languages have lists. Usually this lists are either a nil atom (empty list) or a cons (a couple whose second element is a list). It is easy to see how we can append things to the head of the list.
In my former article we explored lists and foldl. Indeed, it is clear that [...]
Accumulators and Foldl in declarative languages
Saturday, November 8th, 2008
Using accumulators in declarative programming is common. Basically it is possible to convert not tail recursive functions into tail recursive ones using an accumulator.
Consider a very simple procedure: sum numbers in a list. The naive implementation is:
naive_sum([]) ->
0;
naive_sum([H|T]) ->
H + naive_sum(T).
This one is not tail recursive. Every [...]
Extol of Declarativeness
Thursday, November 6th, 2008
Far too many programmers underestimate the beauty of declarative programming. This is something which cames from the industry: functional languages are traditionally under-employed and perceived as academic choices. In fact a lot of research has been done with Lisp and Prolog (mostly in U.S.A. and Europe respectively) in AI and formal languages fields.
However, declarative languages [...]
Do not program defensively. (Sure?)
Saturday, November 1st, 2008
How it is true that pragmatics matters in programming! That is to say, best practices in a given environment/platform may be bad practices in another. For example the following lines are quoted from Erlang’s Programming Rules as recommended from Ericsson:
A defensive program is one where the programmer does not “trust” the input data to the [...]