Clojure Elements: Data Structures and Functions

Keywords

ver. 1.0.0

Practical Clojure fundamentals: REPL-driven development, core types and collections, function and control-flow forms, recursion and sequence-oriented iteration

This unit teaches practical, REPL-centered Clojure programming. You learn to use the REPL and its tooling, work with Clojure’s scalar types and numeric tower, distinguish symbols and keywords, choose and operate on lists, vectors and maps, and rely on the ISeq abstraction. You also define functions and locals, sequence side effects, pick the appropriate conditional form, replace imperative loops with recur and sequence functions, use list comprehensions, and make nested code readable with threading macros.

By the end of the unit you can drive development at the REPL and use its conventions and helper tools to explore code and results. You understand prefix notation and why it makes code generation and manipulation straightforward. You will correctly handle Clojure’s scalar values — nil and its truthiness rules, booleans, characters and Java strings, and the number tower (integers, big integers, ratios, bigdec, floats) including how mixed arithmetic chooses a resulting numeric type.

You can distinguish between symbols (identifiers that resolve to values) and keywords (self-evaluating, often used as keys), and choose appropriate collection types: lists for linked, code-shaped sequences (with front-oriented conj and stack ops), vectors for indexed access, and maps for associative lookup — including nested helpers like assoc-in / get-in / update-in. Because every collection can present an ISeq, you can write generic code using first/rest/cons and use map, filter, reduce, remove and other sequence functions uniformly.

You will define named functions and anonymous ones (defn as def+fn), introduce lexical locals with let, and sequence side effects with do. You’ll select from if, if-not, cond, when and when-not based on negation and else-branch needs, and you will use logical operators (and/or) knowing they return values, not just booleans.

Imperative loops are replaced by idiomatic approaches: loop/recur for tail-recursive, stack-safe iteration; doseq/dotimes for side-effectful repetition; map/filter/for/reduce and for-comprehensions with :when for sequence construction. Finally, you will make nested calls readable with the threading macros (-> / ->>) to express pipelines in execution order. With this vocabulary you can structure small Clojure programs, iterate functionally, and continue into deeper topics like metadata, vars, namespaces and destructuring.

Materials

Source document

  • Clojure in Action (2nd Edition), A. Rathore and F. Avila, Manning, Dec. 2015 — Link — Page 39-77