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

March 30, 2008


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

Verify your Comment

Previewing your Comment

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

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.


Post a comment

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

Your Information

(Name is required. Email address will not be displayed with the comment.)