-
-
Save pjstadig/1104978 to your computer and use it in GitHub Desktop.
Why can't I recur here?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn calculate | |
"A list of coin-values from coins, which sum to target" | |
[coins target acc] | |
(let [coin (max-coin coins target)] | |
(recur coins | |
(- target coin) | |
(cond | |
(not coin) (js-alert "No solution") | |
(= coin target) (list coin) | |
(< coin target) (cons coin acc)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment