Anonymous user
Count the coins: Difference between revisions
→{{header|Common Lisp}}: simpler and more idiomatic code
(Updated D entry n.4) |
(→{{header|Common Lisp}}: simpler and more idiomatic code) |
||
Line 387:
=={{header|Common Lisp}}==
<lang lisp>(defun count-change (amount coins
&optional
(let ((cache (make-array (list (1+ amount) (length coins))▼
:initial-element nil)))▼
(cond ((< l 0) 0)
▲ ((recur (n coins &optional (l (1- (length coins))))
(+ (count-change (- amount (first coins)) coins l cache)
; (compile 'count-change) ; for CLISP
|