(defun check (filename) (let ( (file (open filename)) ) (check-file file 0) ) ) (defun check-file (file level) (let ( (ch (read-char file nil :eof)) ) (if (eq ch :eof) (if (eq level 0) (format nil "All good! You're a bracket matching god.") (if (> level 0) (format nil "You have ~D too many OPEN parentheses." level) (format nil "You have ~D too many CLOSE parentheses." (- level)) ) ) (cond ( (eq ch #\() (check-file file (+ level 1)) ) ( (eq ch #\)) (check-file file (- level 1)) ) ( 't (check-file file level) ) ) ) ) )