GNU/Linux
•
alacritty
•
bash
2 views
Logic and Functional Programming 2026B · TecNM Campus Tijuana Student: Sebastián Martínez García · Control No. 22211608 · List No. 27 · Group 4pm
Live demo of 10 introductory Erlang programs, compiled and run in the erl shell on an AWS Academy EC2 instance (Ubuntu, Erlang/OTP 27). All values are personalized using the list number as the seed (N = 27).
Exercises
-
Shell arithmetic ·
(27 * 7) + 25 = 214,27 rem 4 = 3 - Atoms and tuples · extracting a name with pattern matching
-
Lists · first and last element with
hd/1andlists:last/1 -
Pattern matching ·
{9, 6}→X*X + Y*Y = 117 -
Simple function ·
duplicar(27) = 54 -
Recursion (factorial) ·
factorial(7) = 5040 -
Recursion over lists ·
suma_lista([1..7]) = 28 -
caseexpression ·clasifica(7) = positivo -
Guards ·
es_par(27) = false -
Custom module ·
martinez_garcia:saludo()
Debugging
-
dbgcall tracing onfactorial/1, showing every recursive call and return value -
try/catchto capture abadargerror fromhd([])without crashing the shell -
Reading real errors live:
syntax error,undef, and shell variable rebinding fixed withf/1
📄 Source code and documentation: https://gist.github.com/Gamase/c6dad51238440a1e3a788ae8f340d263