Arithmetic/Integer: Difference between revisions

don't use EVAL
(→‎TI-89 BASIC: new example)
(don't use EVAL)
Line 173:
=={{header|Common Lisp}}==
 
<lang lisp>(defun arithmetic (&auxoptional (a (read *query-io*)) (b (read *query-io*)))
(mapc
(lambda (op &aux (form (list op a b)))
(format t "~a => ~a~%" form(list op a b) (evalfuncall (symbol-function op) a formb)))
'(+ - * mod rem floor ceiling truncate round expt)))</lang>
(values))</lang>
 
Common Lisp's integer division functions are <code>floor</code>, <code>ceiling</code>, <code>truncate</code>, and <code>round</code>. They differ in how they round their quotient.