News for hackers. Stuff that matters.
Re:Ask HN: Why do functional programmers hate loops (for, wh... by iroddis on Tuesday July 11, 2023 @10:02AM (#36681125)
I don’t think that’s much clearer at all. I realize that you’re citing a specific example, but if your approach is to understand the problem first, then you may as well use the closed-form solution of your problem:

sum(1,n) = n*(n+1)/2

Which some compilers will produce for you, even if you use loops.

Maybe if you chose a different example, like generating power sets or the Fibonacci sequence, your point would be better made?

There are no comments on this comment yet.