23 lines
598 B
Common Lisp
23 lines
598 B
Common Lisp
;;; FILES 3: PRINTING TO STREAMS (solution)
|
|
|
|
(defun two-views (x)
|
|
(with-output-to-string (s)
|
|
(prin1 x s)
|
|
(princ " " s)
|
|
(princ x s)))
|
|
|
|
(defun name-tag (name)
|
|
(with-output-to-string (s)
|
|
(print "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"))
|