summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Thompson <dthompson2@worcester.edu>2014-01-31 18:26:16 -0500
committerDavid Thompson <dthompson2@worcester.edu>2014-02-02 15:07:40 -0500
commitc24e06d026e6d75a5f3d8c0522c64d07301caae8 (patch)
tree35c6a2f2b60dea9b11e782af6cc13b7df861282a
Solve Problem 2.
-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))