Wave 4: add sequences/vectors/files chapters, 23 exercises, quiz3, finish ceremony, PCL table
This commit is contained in:
1 parent
77843402fa
commit
4675bd1106
76 files changed
+2505
-14
No files matched your search
@@ -0,0 +1,36 @@
|
||||
;;; FILES 3: PRINTING TO STREAMS
|
||||
;;;
|
||||
;;; PRIN1 prints readably - what the reader could read back, quotes
|
||||
;;; included. PRINC prints for humans - no quotes. PRINT is PRIN1
|
||||
;;; with a newline in front and a space behind. They all take the
|
||||
;;; stream as their second argument.
|
||||
;;;
|
||||
;;; WITH-OUTPUT-TO-STRING makes a stream that collects into a
|
||||
;;; string, so checks can watch printing without a file:
|
||||
;;;
|
||||
;;; (with-output-to-string (s)
|
||||
;;; (princ "hi" s)) => "hi"
|
||||
|
||||
;; TODO: X twice: readable, one space, then plain.
|
||||
(defun two-views (x)
|
||||
(with-output-to-string (s)
|
||||
(princ x s)
|
||||
(princ " " s)
|
||||
(princ x s)))
|
||||
|
||||
;; TODO: The label "name:" on its own line - PRINT starts the line
|
||||
;; - then NAME after it, printed plainly.
|
||||
(defun name-tag (name)
|
||||
(with-output-to-string (s)
|
||||
(princ "name:" s)
|
||||
(princ name s)))
|
||||
|
||||
;;; ------------------------------------------------------------------
|
||||
;;; Checks. Read them - they tell you what to aim for - but leave
|
||||
;;; them unchanged.
|
||||
;;; ------------------------------------------------------------------
|
||||
|
||||
(check-equal "\"hi\" hi" (two-views "hi"))
|
||||
(check-equal "7 7" (two-views 7))
|
||||
(check-equal "
|
||||
\"name:\" ada" (name-tag "ada"))
|
||||
Reference in new issue
Block a user