jonnifyelixir

Chapter F1 · nine lessons

Algebra.

The first crossing. Before a single line of Elixir, one thing becomes plain: the algebra you already know — functions, substitution, composition — is functional programming.

Each lesson pairs one algebraic idea with the Elixir it becomes: a function is a first-class value, substitution is referential transparency, composition is the pipe, and the higher-order operators Σ and Π are a fold. Read in order, the chapter is a dictionary you already half-know — nine lessons that turn quiet intuition into the foundation everything after it rests on.

f ∘ g x g f f(g(x)) x ↦ f(g(x)) — compose functions, and that is the whole game

The arc of the chapter

Nine lessons in four movements. Foundations fix what a function, a substitution, and a composition are. Structure adds immutable values, collections, and recursion. The operators generalise sums and products into folds and solve equations by their shape. The lab plots and composes functions you can drag.

Select a stop on the path to see what it covers.

The journey · select a lesson

FOUNDATIONS STRUCTURE THE OPERATORS THE LAB 1 function 2 substitute 3 compose 4 immutable 5 sets 6 recursion 7 Σ and Π 8 matching 9 lab start here lab
What a function really is

A rule that sends each input to exactly one output — the whole of functional programming starts here.

F1.01 · lesson Foundations available now

The chapter is a single line of reasoning: settle what a function is, learn the operators that act on it, then compose those operators into programs.

A function is a mapping

A function sends each input to exactly one output — that is the entire definition. Pick a rule and watch the whole mapping redraw at once, with nothing mutated and every input carrying exactly one arrow. In Elixir the same idea is written fn x -> … end.

A mapping · choose a rule f : A → B

A (inputs) B (outputs)
—

F1 · Algebra

A function f : A → B is a rule sending each element of the domain to one element of the range.

Elixir

A first-class value: f = fn x -> x + 2 end — pass it, return it, compose it.

Every input has exactly one arrow. Switch the rule and the mapping redraws whole — the mathematical meaning and the Elixir value are the same object.

The algebra you already speak

Functional programming did not invent its ideas — it inherited them from algebra. Map the vocabulary once and Elixir stops looking foreign.

algebraElixir / FP
a function f : A → B→a function (first-class)
substitution→referential transparency
composition f ∘ g→the pipe |>
x is a fixed value→immutable data
Σ, Π over a set→reduce / fold
recursive definition→recursion (no loops)
solving by structure→pattern matching

None of this is a metaphor. An Elixir pipeline is a composition of functions; an Enum.reduce is a finite sum written generally; pattern matching solves an equation by its shape. F1 makes each correspondence explicit.

The nine lessons

Foundations

F1.01 · What a function really is — start here
Mappings, domain, and range: each input goes to exactly one output.
F1.02 · The substitution model — available
Replace equals with equals; an expression is its value — referential transparency.
F1.03 · Composition, f ∘ g — available
Chain small functions into larger ones; composition is associative — the pipe.

Structure

F1.04 · Immutability & binding — available
A symbol names a fixed value; you rewrite expressions, never mutate.
F1.05 · Sets, sequences & mappings — available
Collections, and applying one function across all of them at once.
F1.06 · Recursion & induction — available
Define a thing in terms of itself: base case and step; prove it by induction.

The operators

F1.07 · Higher-order operators — Σ and Π — available
Operators that take functions; sums and products as a single fold.
F1.08 · Equations & pattern matching — available
Identities, solving, and matching a value by its structure.

The lab

F1.09 · Functions on the plane — a plotting lab — available
Plot and compose functions, and watch f ∘ g take shape as curves you can drag.

Where this sits

F1 is the first of six chapters. It precedes F2 · Functional Programming, which takes this algebra off the page and makes it the working style of Elixir; F3 · The Elixir Language, which grounds the ideas in syntax, modules, and tooling; and F4 · Algorithms & Data Structures, where persistent structures and folds do real work. Read in order, each chapter is a consequence of the one before.

Begin with F1.01 — What a function really is, the foundation the rest of the chapter rests on.