TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Transformation Priority Premise Applied

1 pointsby Adrockover 12 years ago

1 comment

Adrockover 12 years ago
The author walks through the iterative construction of the following Clojure code for figuring out how to make a specified amount out of coin denominations:<p><pre><code> (defn change-for [amount] (let [denominations [25 10 5 1] amounts (reductions #(rem %1 %2) amount denominations) coins (map #(int (/ %1 %2)) amounts denominations)] (mapcat #(take %1 (repeat %2)) coins denominations))) </code></pre> He does it while trying to minimize the "cost" of the code, which is defined in an interesting way for anyone who mostly writes imperative code.