News for hackers. Stuff that matters.
Re:Ask HN: Why do functional programmers hate loops (for, wh... by menotyou on Tuesday July 11, 2023 @09:56AM (#36681039)
I would argue

  sum(0) = 0
  when n != 0: sum(n) = n + sum(n-1) 
is kind of clearer. But quite often it is not that easy to give an recursive solution for an iterative problem. When you want to change every even number in an array/list from n to n+1 you can somehow do it recursively, but it is mor obvious to iterate over the elements (which in many functional languages can be expressed by "apply" or some similar function).

There are no comments on this comment yet.