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 @@
;;; NUMBERS 4: TYPE DECLARATIONS (solution)
(defun counted-double (n)
(check-type n integer)
(* 2 n))
(defun shrink (n)
(check-type n (integer 0 100))
(- 100 n))
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check-equal 10 (counted-double 5))
(check-equal 0 (counted-double 0))
(check-error (counted-double "five") 'type-error)
(check-equal 60 (shrink 40))
(check-equal 100 (shrink 0))
(check-error (shrink 200) 'type-error)
(check-error (shrink -3) 'type-error)