And yet you did it anyway.
It's not about looking fancy. It's about having idiomatic code that's concise and easy to understand (particularly for people who actually know the language).
It won't if you're not stupid about it. Also, you should favor map and fold to foreach. They're generally what you want.
This is still premature optimization. You're just being stupid if you do this because it means that you could've done the task in one map/fold/etc. This is like complaining about the fact that you can write three for loops one after the other that are all fundamentally maps and could be done in one for loop.
Why? You should. Saying save you that doesn't change the fact that this is an incredibly relevant reality. You should know what common standard library functions do. That's part of what makes them idioms.
It's not abusing functional "syntax". It's actually using functional style. Higher-order functions like map and fold are the bread and butter of functional programming. Using a functional programming language without them is absolutely ludicrous.




Reply With Quote
