Comment

Comment by adityaathalye

In Clojure...

  ((fn [xs ret]
     (if (empty? xs)
       ret
       (recur (rest xs)
              (+ ret (first xs)))))
   (range 5) 0)

  => 10
nb. Clojure doesn't have automatic tail call optimisation. We need to explicitly emulate it with`recur`.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton