I checked this with my R6RS implementation and it works just as you would expect (https://github.com/maplant/scheme-rs)
(Just me suggesting other alternatives right now)
((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`.Is Racket a good language to pick up and re-learn my concepts + implement some tools? Or are there some other languages that would be better to both brush up and learn the syntax of, I do not want to fight the syntax but rather express functions as seamlessly as I can.
(define-syntax rec
(syntax-rules ()
((rec (NAME . VARIABLES) . BODY)
(letrec ( (NAME (lambda VARIABLES . BODY)) ) NAME))
((rec NAME EXPRESSION)
(letrec ( (NAME EXPRESSION) ) NAME))))
[0] https://srfi.schemers.org/srfi-31/srfi-31.html