3 ms·
Actually, for loops in languages like Ruby and OCaml are just syntactic sugar for map. Also, why would you prefer an imperative construct over different kinds
by steinuil 9y ago
Actually, for loops in languages like Ruby and OCaml are just syntactic sugar for map.
Also, why would you prefer an imperative construct over different kinds of folds?
- crimsonalucard 9y agoI don't. My point is, it's all sugar, so in a sense it's the same thing when you're doing imperative programming. Whether you use a map or a for loop in your imperative code the structure of your program remains the same, the only difference is sugar... This is my point. Why are maps and folds so prevalent in functional programming? Because immutability and imperativeness render the concept of a for loop to be non-existent. Try to use a for loop with all const variables and no IO... your for loop will not be able to do any meaningful change to the state of your program.