Arithmetic/Integer: Difference between revisions
Content added Content deleted
(→TI-89 BASIC: new example) |
(don't use EVAL) |
||
Line 173: | Line 173: | ||
=={{header|Common Lisp}}== |
=={{header|Common Lisp}}== |
||
<lang lisp>(defun arithmetic (& |
<lang lisp>(defun arithmetic (&optional (a (read *query-io*)) (b (read *query-io*))) |
||
(mapc |
(mapc |
||
(lambda (op |
(lambda (op) |
||
(format t "~a => ~a~%" |
(format t "~a => ~a~%" (list op a b) (funcall (symbol-function op) a b))) |
||
'(+ - * mod rem floor ceiling truncate round expt)) |
'(+ - * mod rem floor ceiling truncate round expt)) |
||
(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. |
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. |