Permalink
Browse files

another impl

  • Loading branch information...
1 parent 3a63b33 commit b76dfa6a63b35ac07ef7a6a6ad974b57d31f793d @trenton trenton committed Oct 29, 2009
Showing with 4 additions and 0 deletions.
  1. +4 −0 scala/002/02.scala
View
@@ -0,0 +1,4 @@
+
+// http://scala-blogs.org/2007/12/project-euler-fun-in-scala.html
+lazy val fib: Stream[Int] = Stream.cons(0, Stream.cons(1, fib.zip(fib.tail).map(p => p._1 + p._2)))
+println(fib.filter(_ % 2 == 0).takeWhile(_ <= 4000000).foldLeft(0L)(_ + _))

0 comments on commit b76dfa6

Please sign in to comment.