3 ms·
fold is a library function that is very general, and would be built-in in most other languages (if it existed at all). You wouldn’t write most functions like th
by thewakalix 5y ago
fold is a library function that is very general, and would be built-in in most other languages (if it existed at all). You wouldn’t write most functions like that.
A long variable name only makes sense when the variable is specific. In fold, you have “a function”; nothing else can be said about it. And since working with “a function” is very common, Haskell programmers have converged on a shorthand for it: f. Sure, it’s harder for an entirely new programmer to understand, but every language has practices like this that need to be learned: take “i” in a for-loop in C.
- agumonkey 5y agoThat's quite removed from reality. In java8+ you'd have to import a BiFunction class to be able to talk about a fold. Don't underestimate the mainstream.