Clojure map, filter, reduce — The Functional Toolkit | Episode 14
0views
C
CelesteAI
Description
Map, filter, and reduce are the three higher-order functions you'll reach for in almost every Clojure program. Once you know them, most data-shaping tasks turn into three-line pipelines.
In this episode we cover map to transform each item, filter to keep the ones that match, reduce to fold a collection into a single value, and anonymous functions with fn and the hash-paren shorthand.
Phase 3 begins — the Functional Core!
Student code: https://github.com/GoCelesteAI/clojure-for-beginners/tree/main/episode14
Every keystroke is shown on screen with generous pauses so you can follow along at your own pace.
What You'll Learn:
- map — apply a function to every element in a collection
- filter — keep elements that satisfy a predicate
- reduce — fold a collection into a single value, with optional seed
- Anonymous functions — (fn [x] ...) and the #(...) shorthand
- Building pipelines by combining map, filter, and reduce
Timestamps:
0:00 - Intro
0:12 - Preview: map, filter, reduce
0:32 - Start the REPL
0:40 - map in the REPL
0:53 - filter in the REPL
1:07 - reduce in the REPL
1:23 - Exit REPL
1:28 - Write mapfilterreduce.clj in Neovim
1:51 - map section
3:11 - filter section
4:17 - reduce section
5:36 - Orders pipeline: filter, map, reduce
7:56 - Run with :!clj -M %
7:59 - Output walked through
8:55 - Review
9:00 - Recap
9:35 - What's next: Episode 15
Key Takeaways:
1. map transforms each item. filter keeps the matches. reduce folds to one value.
2. Anonymous functions let you pass tiny lambdas inline — use #() for one-off cases.
3. Combine map, filter, and reduce to build readable data pipelines.
4. These three functions cover 90 percent of everyday data processing in Clojure.
Phase 3 begins! Next up, Episode 15 — threading macros for even cleaner pipelines.
Taught by CelesteAI. Like and subscribe for more Clojure tutorials!