Course

Clojure from the ground up

A Lisp where the data never changes under you

  • Beginner
  • 12 chapters
  • 205 min read

Learn Clojure by writing it: forms and println, names and values, vectors, maps and sets, decisions with if and cond, functions you define yourself, local names with let, loop and recur, recursion and the stack, map and filter and reduce, the threading arrows, sorting and grouping a pile of rows, ending with a small orders report built from all of it.

What You'll Learn

  • Read and write forms, and print with println, print and prn
  • Name values with def, and tell numbers, strings and keywords apart
  • Read and update vectors, maps and sets with get, assoc and conj
  • Choose a branch with if, when and cond, using the two-value truth rule
  • Define functions with defn, including more than one way to call them
  • Keep a name local with let, and take a map or a vector apart as it goes in
  • Repeat work with loop and recur instead of a loop statement
  • Write a recursion that ends, and know when the stack is the limit
  • Pass functions to map, filter, reduce and apply, including short ones
  • Unroll a nest of calls with the threading arrows, first and last
  • Sort, count and group rows, and print a report that reads the same every time
  • Compose a small report from records held as maps in a vector

Prerequisites

  • No programming experience needed — this course starts at the first bracket
  • Any other language you know will make the early chapters quick

Course Content

  1. 01
    Your first Clojure

    What Clojure is, why the operation comes first, and the three ways a program says something out loud.

    Beginner · 14 min read

    Not started
  2. 02
    Names, numbers and text

    Naming a value with def, the kind of numbers Clojure keeps without rounding, and the difference between a string and a keyword.

    Beginner · 15 min read

    Not started
  3. 03
    Vectors, maps and sets

    The three collections you use every day: a row of values, a table of keys, and a bag that answers yes or no when you ask.

    Beginner · 16 min read

    Not started
  4. 04
    Deciding what to do

    if, when and cond, plus the truth rule that makes Clojure decisions easy to read: only nil and false mean no.

    Beginner · 14 min read

    Not started
  5. 05
    Functions you write

    defn, a name that can be called in more than one way, arguments taken apart as they arrive, and the value a function hands back.

    Intermediate · 16 min read

    Not started
  6. 06
    Local names with let

    let for names that live inside one piece of code, a map or a vector taken apart on the way in, and why naming a value once beats writing it twice.

    Intermediate · 16 min read

    Not started
  7. 07
    Loop and recur

    How Clojure repeats work without a loop statement: names for the values that change, and recur to start the next pass with new ones.

    Intermediate · 18 min read

    Not started
  8. 08
    Recursion, and the stack

    A function that calls itself on a smaller problem, the stopping case that ends the walk, and why one shape of recursion runs out of room.

    Intermediate · 18 min read

    Not started
  9. 09
    Functions that take functions

    Passing a function to another function: map, filter, reduce and apply, plus the short spelling for a function you only need once.

    Advanced · 18 min read

    Not started
  10. 10
    Passing the value along

    The two arrows that unroll a nest of calls into lines you can read: the value goes in first with one arrow, last with the other.

    Advanced · 16 min read

    Not started
  11. 11
    Sorting, counting and grouping

    Turning a pile of rows into a report: sort-by on a key, group-by into buckets, frequencies to count, and doseq to print one line at a time.

    Advanced · 20 min read

    Not started
  12. 12
    A small report, end to end

    An orders report built out of everything in the course: maps in a vector, threading with filter, sort-by and map, and one line printed per order.

    Advanced · 24 min read

    Not started