Erlang Functions

Erlang Variables

As you know by now, Erlang is a functional programming language. In my point of view, different programming has different problem solving philosophy:
- Procedural: describe the steps needed to be taken to solve the problem.
- Logical (Declarative): describe the problem properly and let the language solve it.
- Object-orientation: design the objects that will lead you to the solution.
- Functional: define small and precise functions that all together solve the problem.

Declaring a Function

Syntax:

1
2
3
4
function_name(Argument1, Argument2, ...) ->
  Statement1,
  Statement2,
  ...

Example:

example.erl
1
2
3
4
-module(example).
-export([double/1]).

double(N) -> 2 * N.