Currency: Difference between revisions

m
Common Lisp syntax tweaks
imported>GoulashAmateur
(Add Common Lisp version)
imported>GoulashAmateur
m (Common Lisp syntax tweaks)
Line 554:
 
=={{header|Common Lisp}}==
Let us just use the built-in and convenient rationals (which usesuse two bignums for numerator and denominator).
 
<syntaxhighlight lang="lisp">(defun print-$ (rat &key (prefix "") (stream t))
Line 562:
(defun compute-check (order-alist tax-rate)
(let* ((total-before-tax
(loop :for (amount . price) in order-alist
:sum (* (rationalize price) amount)))
(tax (* (rationalize tax-rate) total-before-tax)))
(print-$ total-before-tax :prefix "Total before tax: ")
Line 599:
(defun compute-check (order-alist tax-rate)
(let* ((total-before-tax
(loop :for (amount . price) in order-alist
:sum (* price amount)))
(tax (* (rationalize tax-rate) total-before-tax)))
(print-$ total-before-tax :prefix "Total before tax: ")