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

March 30, 2008

TrackBack

TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00e55055486e883300e55090ba438833

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

Comments

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

Benabik

The simpler way to write

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

is

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.