Hacker News new | ask | show | jobs
by Evbn 4979 days ago
How do you write a function to sum a list of a billion elements in Haskell?

What would happen without tail call elimination?

1 comments

With foldl', of course. If you don't have tail recursion elimination, foldl' would have to be provided as a built-in.

Summing up numbers is inherently strict, so you'd want tail call elimination for that. But functional mainstains, like say, map or filter are usually not implemented with tail recursion in Haskell, because that would be too strict and would break on infinite lists.