Tutorial by Examples

There are two things you will need to know when writing a "hello world" application in Erlang: The source code is written in the erlang programming language using the text editor of your choice The application is then executed in the erlang virtual machine. In this example we will inte...
An erlang module is a file with couple of functions grouped together. This file usually has .erl extension. A "Hello World" module with name hello.erl is shown below -module(hello). -export([hello_world/0]). hello_world() -> io:format("Hello, World!~n", []). In the...
Function is a set of instructions, which are grouped together. These grouped instructions together perform certain task. In erlang, all the functions will return a value when they are called. Below is an example of a function that adds two numbers add(X, Y)-> X + Y. This function performs an...
List comprehensions are a syntactic construct to create a list based on existing lists. In erlang a list comprehension has the form [Expr || Qualifier1, ..., QualifierN]. Where qualifiers are either generators Pattern <- ListExpr or filter like integer(X) evaluating to either true or false. Th...
Starting the Erlang shell On a UNIX system you start the Erlang shell from a command prompt with the command erl Example: $ erl Erlang/OTP 18 [erts-7.0] [source] [64-bit] [smp:8:8] [async-threads:10] [hipe] [kernel-poll:false] Eshell V7.0 (abort with ^G) 1> The text that shows when y...
One of the most common operations in erlang is pattern matching. It is used when assigning a value to a variable, in function declarations and in control-flow structures like case and receive statements. A pattern matching operation needs at least 2 parts: a pattern, and a term against wich the patt...

Page 1 of 1