3 ms·
Well, TCO seems to work: (define (count x) (let loop ((x x) (sum 0)) (if (zero ? x) sum (loop (- x 1) (+ sum x)))))
by edw 15y ago
Well, TCO seems to work:
(define (count x)
(let loop ((x x) (sum 0))
(if (zero ? x)
sum
(loop (- x 1) (+ sum x)))))
(count 100000) ; ==> 5000050000 (doesn't blow up)
I'm very tempted to help out however I can. I've been dreaming of using Scheme instead of JS in a Node.js setting.