Prelude> sum [1, 2, 3] 6
Hey, you could even search for a library that sums lists for you in C, then include and call that function.
Prelude> sum [1, 2, 3] 6
Hey, you could even search for a library that sums lists for you in C, then include and call that function.
const auto & xs = {1, 2, 3};
cout << accumulate(begin(xs), end(xs), 0);A sum function is not very `function' at all. (It sure feels at home in functional languages, more than in imperative bit-by-bit piecemeal programming, sure.)
However, FP is not a silver bullet either. In practice I think humans care a bit less about correctness than compilers and would like some aspects of the language to be 'fuzzy' for lack of a better word. To most people "1" and 1 are the same thing so why shouldn't the compiler understand that. There could be potential for a dynamic-fp language of sorts.
[1] http://blog.sigfpe.com/2006/11/from-l-theorem-to-spreadsheet...
Ie even in Haskell as it is, it's pretty easy to add an 'if' that takes 'truthy ' and 'falsy' values like in Python. Just use a type-class 'Booly' that include a conversion function toBool.