« 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

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been saved. Comments are moderated and will not appear until approved by the author. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment

Comments are moderated, and will not appear until the author has approved them.