Files

21 lines
598 B
Common Lisp

;;; FILES 1: WITH-OPEN-FILE (solution)
(defparameter *note-file* "lisplings-note.txt")
(defun save-note ()
(with-open-file (out *note-file* :direction :output :if-exists :supersede)
(format out "(lisp is lovely)~%")
t))
(defun load-note ()
(with-open-file (in *note-file*)
(read in)))
;;; ------------------------------------------------------------------
;;; Checks. Read them - they tell you what to aim for - but leave
;;; them unchanged.
;;; ------------------------------------------------------------------
(check (save-note))
(check-equal '(lisp is lovely) (load-note))