Because (a) we don't have an unambiguous definition of what functional programming is and (b) we don't have a better term for what this style of programming is.
I guess it could be called combinator-oriented programming or similar.
I guess it could be called combinator-oriented programming or similar.
> It beats complex for-loops
Nvm. I still prefer for loops in most cases, in some way it's easier to understand for me if I read it some months later. For example the reduce function I would write something like this:
getPlayersByCountry= ( footballPlayers= [], players= {} ) ->
for player in footballPlayers
if players.hasOwnProperty player.country
players[ player.country ].push player
return players
playersByCountry= getPlayersByCountry footballPlayers, {France: [], England: [], Spain: []}
I guess it's mere a matter of taste.For that example, you should really have a generic "group by" function to use anyway that plays nice with your map, filter and reduce functions.
That's the benefit of this declarative approach, it removes the relentless boilerplate, works solely with intent, and reduces cyclomatic complexity.