Comment

Comment by twii

As mentioned in one of the comments, this is nowhere near the definition of functional programming.

> 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.
parent twii 9 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton