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

  1. Shell arithmetic · (27 * 7) + 25 = 214, 27 rem 4 = 3
  2. Atoms and tuples · extracting a name with pattern matching
  3. Lists · first and last element with hd/1 and lists:last/1
  4. Pattern matching · {9, 6} → X*X + Y*Y = 117
  5. Simple function · duplicar(27) = 54
  6. Recursion (factorial) · factorial(7) = 5040
  7. Recursion over lists · suma_lista([1..7]) = 28
  8. case expression · clasifica(7) = positivo
  9. Guards · es_par(27) = false
  10. Custom module · martinez_garcia:saludo()

Debugging

  • dbg call tracing on factorial/1, showing every recursive call and return value
  • try/catch to capture a badarg error from hd([]) without crashing the shell
  • Reading real errors live: syntax error, undef, and shell variable rebinding fixed with f/1

📄 Source code and documentation: https://gist.github.com/Gamase/c6dad51238440a1e3a788ae8f340d263

More recordings by gamase

Hola Mundo - Erlang 1:55

by gamase