;;;;3.12 Input/Output ;Adam Nelson ;Chet Tobrey (egs :3.12 #| in order for the next two examples to work properly "test.txt" must not exist in the directory|# (eg '(with-open-file(stream "test.txt" :direction :output) (print '(hello there) stream) (princ 'goodbye stream)) :of "using the macro with-open-stream to open a file and associate it with a stream" ) (eg '(with-open-file (stream "test.txt" :direction :input) (list (read stream)(read-char stream)(read stream) (read stream nil 'eof))) :of "using the macro with-open file to open test.txt and associate it with a stream" ) (eg '(delete-file "test.txt") :of "deleting the file so this example can run again and again") (eg '(format t "hello, world") :of " the first argument of the function format is the stream to print to. here we use t to specify the terminal" ) (eg '(format t "~&~a plus ~s is ~f" "two" "two" 4) :of "the format directive ~&~ moves to a fresh line. ~a prints the next argument as princ would") (eg '(let ((numbers '(1 2 3 4 5))) (format t "~&~{~r~^ plus ~} is ~@r" numbers (apply #'+ numbers))) :of "~r prints the next argument which should be a number and ~~@r prints a number as a roman numeral."))