Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Summary

Summary Erlang Essentials

Rating
-
Sold
-
Pages
21
Uploaded on
31-05-2026
Written in
2025/2026

An introductory to Erlang Programming language. Provides adequate basics to get started with Erlang programming.

Institution
Course

Content preview

Erlang Essentials

Vick Preston



Contents
Erlang Shell 1

2.Data Types in Erlang 3
2.2.Binaries and bitstrings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3.Atoms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.4.Tuples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.5.Lists . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.6.Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.7. Pids, ports, and references . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.8.Functions as data: funs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.9. Comparing Terms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.10 Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Core commands to remember . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3.Modules and Functions 8

4. Variables and Pattern matching 9

6. Cases and Expressions 11

7. Funs 13

8.Exceptions, try, and catch 14
8.1 Throwing (raising) exceptions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14

9. Records 15

10. Preprocessing and include files 16

11. Processes 18

12. ETS Tables 19

13. Recursion - Function that calls itself 20


Erlang Shell
The Erlang shell is an interactive REPL(Read, Evaluate, Print, Loop). It enables execution of Erlang
expressions, test code, spawn processes, inspect state, compile modules, debug interactively. starts in :
erl
Erlang/OTP 28 [...]
Eshell V28


1

,1>
Everything in Erlang is an expression. The expressions are evaluated and values are returned.
1> 2 + 3.
5
The period matters. Erlang shell runs in two modes: - Normal mode ; which commands can be edited and
expressions evaluated - Job Control Mode (JCL); Jobs can be started, killed, detached or connected.

Erlang Shell Commands Cheat Sheet

Command Description Example
erl Starts the Erlang shell erl
q(). Quits the shell q().
init:stop(). Gracefully shuts down Erlang VM init:stop().
h(). Displays shell help h().
h(Module). Shows module help h(lists).
h(Module, Function). Shows help for specific function h(lists, map).
f(). Clears all variable bindings f().
f(Var). Clears specific variable binding f(X).
v(N). Retrieves result of shell command v(2).
number N
pwd(). Prints current working directory pwd().
cd(Path). Changes directory cd("/home/user/project").
ls(). Lists files in current directory ls().
c(Module). Compiles and loads module c(math).
l(Module). Reloads compiled module l(math).
nl(Module). Reloads module from disk nl(math).
m(). Lists loaded modules m().
code:all_loaded(). Lists all loaded modules code:all_loaded().
code:is_loaded(Module). Checks if module is loaded code:is_loaded(math).
rr(Module). Loads record definitions from rr(user).
module
rr("file.hrl"). Loads records from header file rr("include/user.hrl").
b(). Shows all variable bindings b().
bt(Pid). Prints stack trace of process bt(Pid).
flush(). Displays and clears mailbox flush().
messages
self(). Returns current process ID self().
processes(). Lists all running processes processes().
process_info(Pid). Displays process info process_info(Pid).
i(). Lists process information summary i().
i(Pid). Shows detailed process info i(Pid).
memory(). Displays VM memory usage memory().
erlang:memory(). Detailed memory stats erlang:memory().
node(). Returns current node name node().
nodes(). Lists connected nodes nodes().
net_adm:ping(Node). Tests connection to another node net_adm:ping('node2@host').
application:which_applications().
Lists running applications application:which_applications().
observer:start(). Opens graphical system monitor observer:start().
timer:tc(Fun). Times execution of function timer:tc(fun() ->
lists:seq(1,1000) end).
spawn(Fun). Creates new process spawn(fun() -> io:format("Hi")
end).


2

, Command Description Example
Pid ! Msg Sends message to process Pid ! hello.
flush(). Reads received messages flush().
Ctrl + G Opens user switch command mode Press in shell
a (after Ctrl+G) Aborts current shell a
c (after Ctrl+G) Continue shell c
i (after Ctrl+G) Interrupt shell i
k (after Ctrl+G) Kill shell process k
q (after Ctrl+G) Quit Erlang VM q



2.Data Types in Erlang
Data in Erlang is usually referred to as terms ,built-in data types include: - Numbers (integers, floats) -
Binaries/Bitstrings - Atoms - Tuples - List(and strings) - Unique identifiers(pid, ports, reference) ###
2.1. Numbers and Arithmetic Erlang has two numerical data types integers and floats . Conversion is done
automatically by most of the arithmetic operations, so there is no need for any type coercion. Integers in
Erlang can be of arbitrary size, they can be written in any base between 2 and 36 (0-9. A-Z/a-z). Floats
are handled by 64-bit IEEE 754-1985 representation (double precision), There are no single precision
floating-point in Erlang.
Normal infix notation is used for common arithmetic operators:
+, -, *
for divisions 2 options exists:
%% yields a floating point number; ---> 2.0
%% div -> 7 div 2 ----> 3
The remainder of an integer division is given by the rem operator. There are some additional integer operators
for bitwise operations: N bsl K shifts the integer, N K steps to the left, and bsr performs a corresponding
arithmetic right shift. The bitwise logic operators are named band,bor,bxor, and bnot. For example,X
band (bnot Y) masks away those bits from X that are set in Y.

2.2.Binaries and bitstrings
In Erlang, binaries and bitstrings are low-level data types used for working with raw binary data efficiently —
things like network packets, file contents, protocol messages, cryptographic data, and serialization. Bitstrings
is a simple sequence of bits, this means it contains any number of bits not necessarily divisible by 8.
%1 = value and 3 = store it using 3 bits.
%001 will be the binary representation.
<<1:3>>
Binary is a bitstring whose size is a multiple of 8 bits (1 byte). Every binary is bitstring and not every
bitstring is a binary. Or a binary is – bitstring where bit_size mod 8 = 0 The relationship:
bitstring
-- binary

2.3.Atoms
Atoms are one of Erlang’s core data types. An atom is a constant whose value is its own name. Think
of them as symbolic labels or named constants. Atom are mainly used as identifiers. They are stored in the
table and referred to by the table index, and they have a length of 255 characters.




3

Written for

Course

Document information

Uploaded on
May 31, 2026
Number of pages
21
Written in
2025/2026
Type
SUMMARY

Subjects

$9.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
softaltmoran

Get to know the seller

Seller avatar
softaltmoran Maseno University
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
1 month
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions