summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--problem-2.scm9
1 files changed, 9 insertions, 0 deletions
diff --git a/problem-2.scm b/problem-2.scm
new file mode 100644
index 0000000..2b4af05
--- /dev/null
+++ b/problem-2.scm
@@ -0,0 +1,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))