Comment by farrellm23
2 days ago
Usually you want `foldl'` (with ' at the end), the strict version of `foldl`. It prevents the creation of intermediate thunks, so effectively a tail recursive iteration over the list in constant space.
`foldr` I almost never use, but it would be for: the return value is a lazy list and I will only need to evaluate a prefix.
The naming conventions are nicely sadistic.
This is what happens when you let Mathematicians name things on chalkboards. They don't want to run out of chalk and they get tired of spelling whole words very easily so they use short names and silly symbols. The name foldl' is "just" "fold left prime". Remember ' means "prime" from calculus class and thinking that was silly even then? Accidentally infected Haskell at a young age.
> This is what happens when you let Mathematicians name things on chalkboards.
Doubly so with APL!
Yeah it's definitely unusual to allow ' to be part of the name of a variable, especially considering that it is, like C, the quote for character types.
1 reply →