Skip to content

Instantly share code, notes, and snippets.

@pjstadig
Forked from mjg123/calculate.clj
Created July 25, 2011 19:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pjstadig/1104978 to your computer and use it in GitHub Desktop.
Save pjstadig/1104978 to your computer and use it in GitHub Desktop.
Why can't I recur here?
(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