News for hackers. Stuff that matters.
Re:Ask HN: Why do functional programmers hate loops (for, wh... by roelschroeven on Tuesday July 11, 2023 @10:49AM (#36681799)
But that can't be tail call optimized, so you should write something like

    sum(n, acc=0) = n == 0 ? acc : sum(n-1, acc+1)
To me that negates much of the 'declarative' character of a functional style. I don't feel it's really clearer than the imperative for-loop

    acc = 0
    for i = 1 to n
        acc += 1

There are no comments on this comment yet.