Comparing Erlang and Prolog

In the back of my mind, I have for a little while known two things:

  1. Prolog is no language for a man to use.
  2. I should probably check out this Erlang thing.

So today I have a look at this getting-started-with-erlang tutorial, and lo! Perhaps my Prolog skills are not so useless after all.


% Erlang
-module(tut4).
-export([list_length/1]).

% simple function to return list length
list_length([]) ->
    0;
list_length([_F|R]) ->
    1 + list_length(R).


% Prolog
:- module(tut4).
:- export list_length/2.

% simple predicate to return list length
list_length([], 0).
list_length([_F|R], L):-
    L is 1 + list_length(R).

Similarities so far:

Differences:

  • About

    Daniel Lucraft, London, UK. Interested in Ruby, Prolog and software.