Wave 4: add sequences/vectors/files chapters, 23 exercises, quiz3, finish ceremony, PCL table

This commit is contained in:
venomade committed 2026-11-22 11:15:35 +00:00
1 parent 77843402fa
commit 4675bd1106
76 files changed
+2505 -14

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
;;; SEQUENCES 2: REMOVE, REMOVE-IF, SUBSTITUTE (solution)
(defun drop-them (x xs)
(remove x xs))
(defun drop-negatives (xs)
(remove-if #'minusp xs))
(defun swap-them (new old xs)
(substitute new old xs))
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check-equal '(a c) (drop-them 'b '(a b c b)))
(check-equal '(1 3) (drop-them 2 '(2 1 2 3 2)))
(check-equal '(1 0 2) (drop-negatives '(-1 1 0 -2 2)))
(check-equal '(3) (drop-negatives '(-5 -3 3)))
(check-equal '(x 2 x) (swap-them 'x 1 '(1 2 1)))
(check-equal '(a b a) (swap-them 'a 'z '(z b z)))