Clojure Lists — Prepend, First, Rest & Stacks | Episode 8

0views
C
CelesteAI
Description
Vectors add to the end. Lists add to the front. That one difference changes everything about when you reach for each one. In this episode we explore lists — Clojure's linked list. We create them with quote, access with first and rest, grow with conj (which prepends!), and build a stack to see the pattern in action. By the end you will know exactly when to use a list versus a vector. Student code: https://github.com/GoCelesteAI/clojure-for-beginners/tree/main/episode08 Every keystroke is shown on screen with generous pauses so you can follow along at your own pace. What You'll Learn: - List literal syntax with quote: '(1 2 3) or (list 1 2 3) - first gives the head, rest gives the tail - conj adds to the FRONT of a list (opposite of vectors!) - cons prepends one item - list? and vector? type checks - Lists vs vectors: conj behavior tells you which you have - Building a stack with conj, peek, and pop Timestamps: 0:00 - Intro 0:12 - Preview: lists add to the front 0:32 - Start the REPL 0:40 - Create lists with quote and list 0:52 - first and rest 1:05 - conj on a list vs. a vector 1:18 - cons 1:24 - Type checks with list? and vector? 1:39 - Exit REPL 1:44 - Write lists.clj in Neovim 2:05 - Create, first/rest, conj sections 3:46 - cons, compare, stack sections 5:51 - Run with :!clj -M % 5:55 - Output explained line by line 6:51 - Review 6:58 - Recap 7:33 - What's next: Episode 9 Key Takeaways: 1. Quote or list creates a list. conj prepends to the front. 2. first gives the head, rest gives the tail — the core linked-list operations. 3. Lists are ideal for stacks and recursive processing. Use vectors for indexed access. 4. conj behavior tells you the type: end for vectors, front for lists. Series Roadmap: - Episodes 1-6: REPL and first values (complete) - Episodes 7-13: Collections and sequences (current) - Episodes 14-19: Functional core - Episodes 20-45: Projects, concurrency, macros, capstone Next up — Episode 9: Maps. Taught by CelesteAI. Like and subscribe for more Clojure tutorials!
Back to tutorials

Duration

Added to Codegiz

April 17, 2026

📖 Read the articleOpen in YouTube