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

+25
View File
@@ -0,0 +1,25 @@
;;; SEQUENCES 1: FIND, POSITION, COUNT (solution)
(defun index-of (x xs)
(position x xs))
(defun occurrences (x xs)
(count x xs))
(defun find-same (x xs)
(find x xs :test #'=))
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check-equal 1 (index-of 'b #(a b c)))
(check-equal 2 (index-of 3 '(1 2 3)))
(check-equal nil (index-of 9 '(1 2 3)))
(check-equal 3 (occurrences 'a #(a b a c a)))
(check-equal 2 (occurrences 'b '(a b a b a)))
(check-equal 0 (occurrences 5 '(1 2 3)))
(check-equal 1 (find-same 1.0 '(2 1 3)))
(check-equal 2 (find-same 2.0 '(1 2 3)))
(check-equal nil (find-same 9 '(1 2 3)))