typestar

Language basics

27 steps in 9 sets of Clojure.

Clojure is the Lisp that moved into industry housing: it runs on the JVM, calls any Java library directly, and rebuilt the Lisp idea around immutable data structures — vectors, maps, and sets you write as literals and transform instead of mutate. Most programs are pipelines: data flows through map, filter, and reduce, threaded left to right with the -> and ->> macros.

This tour covers the working core: def and let, the collection literals and their toolkit, defn with destructuring, nil punning and the everything-is-truthy-except-nil-and-false rule, the sequence library from map to frequencies, and just enough state — one atom, one record — to model change. The encore ships complete programs. Every seed passes a whole-file read gate, and under the run gate every snippet loads and every script runs start to finish.

Start this tour

Values & bindings

  • def & namesNames a market stall's inventory with def, deriving one value from the others.
  • let localsConverts tide pool measurements inside a let, then watches a shadowed name snap back.
  • Keywords & symbolsReads a mixtape track from a map with keywords, then contrasts one with a quoted symbol.

Collections

  • Vector operationsBuilds a ferry route as a vector, then reads it by index, count, and slice.
  • Map lookupTracks seedling counts in a map, then adds, drops, and merges keys.
  • Sets & membershipCompares two birding lists using set literals and clojure.set.

Functions

  • defn basicsDefines a baker's hydration percentage with a docstring and a private helper.
  • Anonymous functionsPasses unnamed functions to map and filter over a week of rainfall readings.
  • Multiple aritiesA watering function with a default arity, plus a variadic label builder.

Flow & truthiness

  • if, when & condTide gauge readings routed through if, when and cond.
  • Truthiness & nilOnly nil and false are falsey; or and and turn that into defaults.
  • case & condpSubway line colors chosen by case on literals, crowding levels by condp.

Sequences

  • map & filterBird sighting counts run through map, filter and mapv.
  • reduce & foldsBakery loaf orders folded with reduce, including a fold into a map.
  • Threading macrosOne elevation pipeline written nested, then with ->>, plus -> over a map.

Seq toolkit

  • frequencies & group-byWord counts with frequencies, then subway stops bucketed by group-by.
  • sort-by & intoA record crate sorted by year and by plays, then poured out with into.
  • comp & partialWeather station readings converted by functions built with comp and partial.

Destructuring

  • Vector destructuringPulls trail waypoints and a coordinate pair apart by position inside let.
  • Map destructuringReads an order map by key, then applies the same form to a function parameter with a default.
  • Varargs and option mapsSums any number of arguments, spreads a vector back into them, and pads a label from an options map.

State & records

  • Atoms and swap!Tracks a visitor count and a front desk register in atoms, updating both through plain functions.
  • Nested map updatesReads and rewrites a two-level tool inventory through key paths instead of hand-nested calls.
  • Protocols and recordsDeclares a billing operation once as a protocol and lets two record types answer it differently.

Encore

  • word_freq.cljCounts words in a short harbor passage and prints the eight most frequent with their share of the text.
  • grade_report.cljAverages three test scores per student, assigns a letter grade, and closes with a class summary.
  • temp_stats.cljReports a week of high temperatures with a scaled bar per day and each day's distance from the mean.

The other Clojure tours