« Using Scala's Option class to help avoid NullPointerExceptions | Main | GWT 1.5 now supports Object.getClass() »

March 30, 2008


TrackBack URL for this entry:

Listed below are links to weblogs that reference Looking at Streams in Scala:


Feed You can follow this conversation by subscribing to the comment feed for this post.


The simpler way to write

Stream.cons(3, Stream.cons(4, Stream.empty))


3 #:: 4 #:: Stream.empty

Which is a fact that's very handy to remember when you're trying to build infinite lists:

val fibs: Stream[Int] = 1 #:: 1 #:: (fibs zip fibs.tail).map{ case (a,b) => a + b }

Lists can be built in the same way by dropping the #:

1 :: 2 :: 3 :: Nil

The comments to this entry are closed.