4 ms·
It's used to replace all looping. A combination of map and reduce is an alternative to loops. Also you don't need map. You can use list comprehension to replac
by corethree 3y ago
It's used to replace all looping. A combination of map and reduce is an alternative to loops.
Also you don't need map. You can use list comprehension to replace map. But list comprehensions can't replace reduce.
Technically reduce can also replace map. The only primitive you need to do all your iterations is technically just reduce.
If you want to get more elegant than you don't even need reduce. You can eliminate all redundant primitives and use functions themselves for iteration. It's Just recursion.
- laurent_du 3y agoIf you use reduce to replace looping, your coworkers probably hate you. Don't write Clojure in Python.
- corethree 3y agoIt's called functional programming. Coworkers don't hate it it's more readable in general to split between map and reduce and forego looping. It's less readable to use reduce for all looping even though technically you can.