Skip to content

Instantly share code, notes, and snippets.

@d11wtq
Created June 24, 2012 14:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d11wtq/2983540 to your computer and use it in GitHub Desktop.
Save d11wtq/2983540 to your computer and use it in GitHub Desktop.
(define (each-fib fn)
(letrec
((next (lambda (a b)
(fn a)
(next b (+ a b)))))
(next 0 1)))
(define (take-n-fibs n)
(call/cc
(lambda (return)
(let*
((lst '())
(fn (lambda (v)
(set! lst (cons v lst))
(set! n (- n 1))
(if (= 0 n) (return (reverse lst))))))
(each-fib fn)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment