From: Thomas A. Russ on 29 Apr 2010 19:16 Tamas K Papp <tkpapp(a)gmail.com> writes: Nice rewrite. > (defparameter *op-table* > '((+ "sum") > (* "product") > (- "difference"))) > > (defun ask-what-is (op arg1 arg2) > (format t "~&What is the ~a of ~a and ~a? " > (second (assoc op *op-table*)) arg1 arg2) > (let* ((result (funcall op arg1 arg2)) > (answer (read)) > (correct-p (= answer result))) > (if correct-p > (format t "~&Correct.") > (format t "~&Nope. The correct is ~a." result)) > correct-p)) Or if you don't mind some fancier format string: (format t "~&~:[Nope. The correct answer is ~a.~;Correct~*~]" correct-p result) -- Thomas A. Russ, USC/Information Sciences Institute
|
Pages: 1 Prev: [els2010] Final call for participation Next: Lispers in the silicon valley? |