Skip to content

Instantly share code, notes, and snippets.

@ldunn
Created November 13, 2009 05:35
Show Gist options
  • Select an option

  • Save ldunn/233622 to your computer and use it in GitHub Desktop.

Select an option

Save ldunn/233622 to your computer and use it in GitHub Desktop.
(defun prompt-read (prompt)
(format *query-io* "~a:" prompt)
(force-output *query-io*)
(read-line *query-io*))
(defun make-calc-prompt ()
(defparameter num1 (parse-integer (prompt-read "First number")))
(defparameter op (prompt-read "Operator (+-/*)"))
(defparameter num2 (parse-integer (prompt-read "Second number")))
(cond
((string= op "+") (return-from make-calc-prompt (+ num1 num2)))
((string= op "-") (return-from make-calc-prompt (- num1 num2)))
((string= op "*") (return-from make-calc-prompt (* num1 num2)))
((string= op "/") (return-from make-calc-prompt (/ num1 num2)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment