3 ms·
I certainly agree with you that `fold` is a terrible name for it. That makes me think of some kind of halving action. "inject:into" is definitely a bit better.
by noneeeed 4y ago
I certainly agree with you that `fold` is a terrible name for it. That makes me think of some kind of halving action.
"inject:into" is definitely a bit better. It's amazing how quite a small addition to a name can make a big difference. I'm always keen on my team using longer method/variable names when it can help with meaning, sometimes just a small expansion can really help readability.
- JadeNB 4y ago> I certainly agree with you that `fold` is a terrible name for it. That makes me think of some kind of halving action. I think the poster expressed no opinion on `fold` itself, only on the obviousness or un- of which way `foldl` folds: that is, ignoring base conditions, afold f z (x:xs) = f x (afold f z xs) can be said to fold from the left, whereas bfold f z (x:xs) = bfold f (f z x) xs can be said to fold to the left. It happens that the latter is what we call `foldl`, but I think one can't reasonably argue that a clean-room re-discovery of folding—which would surely discover both implementations—would be guaranteed to impose the same convention. (As weak evidence for this, I note that I would be willing to bet only a tiny sum of fake internet points that your grandparent would agree on which of these they meant by "fold from the left", and which of these they meant by "fold to the left".)