Skip to content

Instantly share code, notes, and snippets.

@NhanHo
Last active August 29, 2015 14:08
Show Gist options
  • Save NhanHo/914a715328f02f74d765 to your computer and use it in GitHub Desktop.
Save NhanHo/914a715328f02f74d765 to your computer and use it in GitHub Desktop.
(define (next-fibonaci x y) (stream-cons (+ x y) (next-fibonaci y (+ x y))))
(define even-fibo (stream-filter even? (next-fibonaci 0 1)))
(define (take-while-helper s f result)
(if (f (stream-first s))
result
(take-while-helper (stream-rest s) f (cons (stream-first s) result ))))
(define (more-than-4M x) ( > x 4000000))
(apply + (take-while-helper (next-fibonaci 0 1) more-than-4M '()))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment