The canonical factorial in free form is equal to:
fact = product . enumFromTo 1
(which is equivalent to fact n = product [1..n] )
I find this pretty readable. However, I agree that the original version:
fact 0 = 1 fact n = n * (fact (n-1))
It meets the definition very well and is also readable.
The point (ha!) Of dimensionless form is to facilitate the discussion of functions as the composition of other functions. However, the factorial function is not really an excellent candidate for this kind of reasoning.
Your decision is obvious.
John gietzen
source share