Erlang

Why learn it now

I found out that Erlang is still worth learning for those wanting to learn Elixir. Since I recently got interested in the Gleam language as well, I'm just giving it a try.

Syntax

The syntax is remarkably simple as this:

recursive.erl
-module(recursive).
-export(fac/1, tail_fac/1).

% Factorial (Recursion)
% fac/1
fac(N) when N == 0 -> 1;
fac(N) when N > 0 -> N * fac(N - 1).

% Factorial (Tail Recursion)
% tail_fac/1
tail_fac(N) -> tail_fac(N, 1).

tail_fac(0, Acc) -> Acc;
tail_fac(N, Acc) when N > 0 -> tail_fac(N - 1, N * Acc).

Resources

This is the best guide I've found so far:

Last updated