Skip to content

Instantly share code, notes, and snippets.

@sritchie sritchie/money.clj forked from gfredericks/money.clj
Created Jul 10, 2011

Embed
What would you like to do?
mdeboard
(reduce
(fn [[amount-left coins] denom]
(let [{:keys [mod dividend]} (calc-coins amount-left denom)]
(if (pos? dividend)
[mod (assoc coins denom dividend)]
[amount-left coins])))
[amount {}]
denoms)
(fn [[amount {}] 20]
(let [{:keys [mod dividend]} (calc-coins amount-left denom)]
(if (pos? dividend)
[mod (assoc coins denom dividend)]
[amount-left coins])))
(let [{:keys [mod dividend]} (calc-coins 100 20)]
(if (pos? dividend)
[mod (assoc {} 20 dividend)]
[100 {}]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.