Ethiopian multiplication: Difference between revisions

Content added Content deleted
(CL Ethiopian Multiply)
(typo fix in CL multiple/multiply)
Line 200: Line 200:
=={{header|Common Lisp}}==
=={{header|Common Lisp}}==


Common Lisp already has <code>evenp</code>, but all three of <code>halve</code>, <code>double</code>, and <code>even-p</code> are locally defined within <code>ethiopian-multiple</code>. (Note that the termination condition is <code>(zerop l)</code> because we terminate 'after' the iteration wherein the left column contains 1, and <code>(halve 1)</code> is 0.)
Common Lisp already has <code>evenp</code>, but all three of <code>halve</code>, <code>double</code>, and <code>even-p</code> are locally defined within <code>ethiopian-multiply</code>. (Note that the termination condition is <code>(zerop l)</code> because we terminate 'after' the iteration wherein the left column contains 1, and <code>(halve 1)</code> is 0.)


<lang lisp>(defun ethiopian-multiply (l r)
<lang lisp>(defun ethiopian-multiply (l r)