(defn calc-coins [amount denom] {:mod (mod amount denom), :dividend (int (/ amount denom))}) (defn clos [amount] ; denoms is a list containing the currency denominations (let [denoms '(20 10 5 1 0.25 0.10 0.05 0.01)] (reductions ; declaring a function that (fn [[amount-left coins] denom] ; let x equal the result of (calc-coins amount-left denom), which will be ; of type `map` (let [x (calc-coins amount-left denom), ; assign `mod` the value of the keyword `mod` in the mapping ; assigned to `x` mod (:mod x), ; assign `dividend` the value of the keyword `dividend` in the ; mapping assigned to `x` dividend (:dividend x)] ; if `dividend` is positive (i.e. neither negative nor 0): (if (pos? dividend) ; return a vector containing the remainder and a map of a ; denomination to the number of times you could divide it into ; amount-left. This return value will be consumed by reduce. [mod (assoc coins denom dividend)] ; otherwise, return the original input value, which would be ; `[amount {}]`. This should (???) only happen the first pass. [amount-left coins]))) [amount {}] denoms)))