This is probably my single biggest complaint. I spend an inordinate amount of time when writing Go doing tedious, fiddly stuff like this using loops and indexes and accumulators and stuff to perform extremely common operations that could be represented by a single word.
But that assumes reducing line count is the goal; one could argue that functional constructs like that sacrifice length in favor of complexity / cleverness.
Mind you I do like and prefer functional style, I've done a lot of the iteration style processing back in Java 1.5 and never gone back to that yet. Functional style expresses the 'what', whereas iterative style spends a lot of code expressing the 'how'.
I'd spread the operations out over multiple lines, one operation per line at least. But that's a personal style preference.
It needs map, filter, reduce to reduce line count. Swift, while probably not as performant as Go, makes writing in a more Pythonic style.
https://github.com/melling/SwiftCookBook/blob/master/functio...