Erlang
Erlang
Installation
Ubuntu
apt install erlang
Alma Linux
dnf install erlang
Arch Linux
pacman -S erlang
Source Code
# Download otp_src_{version}.tar.gz from https://www.erlang.org/
tar xzf otp_src_{version}.tar.gz
cd otp_src_{version}
./configure [options]... [VAR=VALUE]...
make
make install
Examples
Fibonacci Numbers
% Fibonacci Numbers
-module(fibonacci).
-export([main/1]).
main(Arg) ->
N = list_to_integer(hd(Arg)),
io:fwrite(integer_to_list(fib(N))).
fib(0) -> 0;
fib(1) -> 1;
fib(N) -> fib(N - 2) + fib(N - 1).
% example
% compile:
% erlc fibonacci.erl
% run:
% erl -noshell -run fibonacci main 39 -run init stop