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

+29
View File
@@ -0,0 +1,29 @@
;;; VECTORS 1: MAKE-ARRAY, AREF, AND #(...) (solution)
(defun slot-one (v)
(aref v 1))
(defun replace-first (v x)
(setf (aref v 0) x)
v)
(defun triple-vector (a b c)
(vector a b c))
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check-equal 'b (slot-one #(a b c)))
(check-equal 2 (slot-one #(1 2 3)))
(check-equal 'x
(aref (replace-first (make-array 2 :initial-element 'a) 'x)
0))
(check-equal 99
(aref (replace-first (make-array 3 :initial-element 0) 99)
0))
(check (vectorp (triple-vector 'a 'b 'c)))
(check (equalp #(p q r) (triple-vector 'p 'q 'r)))
(check-equal 'q (aref (triple-vector 'p 'q 'r) 1))
(check-equal 3 (length #(a b c)))