; An alternative implementation of sumloop, ; that stores into the global variable only at the ; end of the loop, written by Will Clinger to test ; Kernighan and Van Wyk's conclusion that this has ; essentially the same performance as their benchmark. (define sum 0) (define (tail-rec-aux i n s) (if (< i n) (tail-rec-aux (+ i 1) n (+ s 1)) (begin (set! sum s) sum))) (define (tail-rec-loop n) (tail-rec-aux 0 n 0)) ; (tail-rec-loop 1000000)