Re:Why Don't Computer Scientists Learn Math?
by chaoxu on Saturday November 19, 2016 @10:42AM
(#12993921)
That map is doing an impure operation. The order of application matters.
Otherwise, for people who learned functional programming from the start, it's much easier to understand.
Re:Why Don't Computer Scientists Learn Math?
by witty_username on Saturday November 19, 2016 @11:32AM
(#12994165)
I find the map solution simpler than the for loop as there is no loop variable.
Re:Why Don't Computer Scientists Learn Math?
by gravypod on Saturday November 19, 2016 @12:00PM
(#12994292)
It's simpler, much simpler, in this context. It's not simpler when you scale up the implementation being used. After you scale it up it stops being simpler and starts being `clever`.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." − Brian W. Kernighan
On the other side of the spectrum you have this:
This is far fewer characters, but it's more difficult to understand. There are more things to understand if you've never done any functional programming. This sort of dense solution is frowned upon in many cases, especially since this sort of thing rarely scales efficiently in the sense of cognitive load. I did all of my CS labs using map/reduce formulas for CS100 and it did nothing but make things harder and drive a large appreciation for expanding statements into my heart.