
On 10 March 2010 11:21, Ketil Malde
[Cited from "Learn You a Haskell for Great Good"]
oddSquareSum :: Integer oddSquareSum = sum . takeWhile (<10000) . filter odd . map (^2) $ [1..]
To me, the first one is very clear, and exposes the function as what it is: a neat, linear pipeline of standard function applications. You don't have to be a very seasoned programmer to quickly identify this structure, or the components involved.
Named values are just like comments, which IMO also should be kept to a bare minimum. A bit tongue in cheek: If you need a name to understand what a function does, or a comment to understand how it does it, then your code is too complicated.
Tongue-in-cheek? It's completely ridiculous. That example above has six names in it. Try recursively replacing all the names in it with their definitions, until the only names left are built-in primitives. -- Colin Adams Preston, Lancashire, ENGLAND