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

+26
View File
@@ -0,0 +1,26 @@
;;; MACROS 5: READER MACROS, A TASTER
;;;
;;; The # you know from #' and #(...) is a dispatch character: the
;;; character after it picks a reader function, and SET-DISPATCH-
;;; MACRO-CHARACTER installs one. The function takes (STREAM
;;; SUB-CHAR NUM-ARG) and returns the object the text becomes -
;;; the reader never evaluates, it only reads.
;;;
;;; (set-dispatch-macro-character #\# #\? #'reader)
;; TODO: Make #? read the NEXT form and hand it back wrapped in
;; (maybe ...): #?red should read as (maybe red). MAYBE-READER
;; below needs the fix; the registration line is already right.
(defun maybe-reader (stream sub-char num-arg)
(declare (ignore sub-char num-arg))
(read stream))
(set-dispatch-macro-character #\# #\? #'maybe-reader)
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check-equal '(maybe red) '#?red)
(check-equal '(maybe (1 2)) '#?(1 2))