summaryrefslogtreecommitdiff
path: root/problem-2.scm
blob: 2b4af057ad998042a385d7b4156f746700bcafd2 (plain)
1
2
3
4
5
6
7
8
9
(use-modules (srfi srfi-41))

(define fib
  (stream-cons 0 (stream-cons 1 (stream-map + fib (stream-cdr fib)))))

(define even-fib
  (stream-filter even? fib))

(stream-fold + 0 (stream-take-while (lambda (x) (< x 4000000)) even-fib))