Lisplings: Rustlings-style exercises for Common Lisp

70 exercises in 20 chapters, from first s-expressions to restarts,
macros, CLOS, and a tiny Lisp interpreter. Each exercise ships
broken with a solved twin and a hint. Includes a watch-mode runner,
a plain-CL check harness, a nix flake, and verification tooling.
All plain SBCL, no dependencies.
This commit is contained in:
venomade committed 2026-11-22 03:30:19 +00:00
commit 4df60ead93
172 files changed
+4403

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
;;; VARIABLES 1: GIVING A NAME TO A VALUE (solution)
(defparameter *room-capacity* 100)
(defun room-full-p (attendees)
(> attendees *room-capacity*))
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check (room-full-p 200))
(check (not (room-full-p 3)))
+18
View File
@@ -0,0 +1,18 @@
;;; VARIABLES 2: LET AND SHADOWING (solution)
(defun shadow-add ()
(let ((x 15))
(let ((x (+ x 5)))
x)))
(defun wrap-me ()
(let ((x 15))
(+ x 5)))
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check-equal 20 (shadow-add))
(check-equal 20 (wrap-me))
+13
View File
@@ -0,0 +1,13 @@
;;; VARIABLES 3: LET AND LET* (solution)
(defun area-ish ()
(let* ((a 3)
(b (+ a 2)))
(* a b)))
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check-equal 15 (area-ish))
+16
View File
@@ -0,0 +1,16 @@
;;; VARIABLES 4: SETF ON PLACES (solution)
(defparameter *account* (list :owner "Ada" :balance 100))
(defun deposit (amount)
(setf (getf *account* :balance)
(+ amount (getf *account* :balance)))
*account*)
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check-equal '(:owner "Ada" :balance 150) (deposit 50))
(check-equal '(:owner "Ada" :balance 170) (deposit 20))