Dabbling in Erlang, part 2: A minimal introduction (2013)

· coding · Source ↗

TLDR

  • 2013 blog post walks through Erlang fundamentals: single assignment, pattern matching, guards, higher-order functions, and list comprehensions with Ruby comparisons.

Key Takeaways

  • = in Erlang is pattern matching, not assignment; unbound variables get bound on match, bound variables must equal the expression.
  • Function clauses with pattern-matched heads replace if/case chains; clause order matters since matching is top-to-bottom.
  • Guards (when X rem 2 == 0) add constraints beyond structural pattern matching without extra conditionals.
  • Lists are recursive cons cells; head/tail extraction and prepend are O(1); [H|T] destructuring is idiomatic.
  • List comprehensions ([X*2 || X <- List, X rem 2 == 0]) combine map and filter in set-builder notation.

Hacker News Comment Review

  • No substantive HN discussion yet.

Original | Discuss on HN