Skip to content

Instantly share code, notes, and snippets.

@takikawa
Forked from anonymous/gist:2669161
Created May 12, 2012 21:33
Show Gist options
  • Save takikawa/2669212 to your computer and use it in GitHub Desktop.
Save takikawa/2669212 to your computer and use it in GitHub Desktop.
(define a -1)
(define b 1)
;; original
(define x ((λ ()
(let ([l '()])
(define (loop i)
(if (< i b)
(begin (append (loop (+ i 1/100)) (list i)))
(append l (list i))))
(reverse (loop a))))))
;; tail recursive
(define x
(let loop ([i a] [lst '()])
(if (< i b)
(loop (+ i 1/100) (cons i lst))
(reverse lst))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment