4 ms·
Ah reduce/fold, if only it were as intuitive as map and filter. Reduce is great for specific circumstances and contrived homework problems. But come back to it
by dntbnmpls 7y ago
Ah reduce/fold, if only it were as intuitive as map and filter. Reduce is great for specific circumstances and contrived homework problems. But come back to it after a while and it confounds you and you have to relearn it. There is elegance to reduce and its solutions and I'm sure many find it intuitive.
- beatgammit 7y agoPersonally, I think that if reduce is a single, reasonable length line, it's probably being used correctly. If it's a giant function, you're probably better off just using a regular loop. Use it when it's clear and elegant, don't when it's not. Unfortunately, relatively junior programmers try to force it because it seems like a cool tool to use.