3 ms·
In terms of cleanly communicating one's intent, I'd also suggest a look at Sean Johnson's talk about letting the function arguments determine what version of th
by lkrubner 11y ago
In terms of cleanly communicating one's intent, I'd also suggest a look at Sean Johnson's talk about letting the function arguments determine what version of the function is used. This is a common idea in most programming languages and some Functional languages, such as Haskell, tend to take it to an extreme. And yet, it is not as common as it should be in Clojure.
One of his rules is "If your function starts with a conditional, get rid of the conditional and look for that pattern in your function arguments." That is, move the conditional into the different versions of your function.
Also, his "Recursive Function Pattern Matching Pattern" makes recursion much easier to read. See the screenshots here and then click through to the video:
http://www.smashcompany.com/technology/the-recursive-function-pattern http://www.smashcompany.com/technology/the-recursive-functio...