Comment on 12.8

13 views
Skip to first unread message

Eric Pederson

unread,
Jan 5, 2013, 5:48:11 PM1/5/13
to fp...@googlegroups.com
After reading the special note for Ruby programmers I thought I would mention that Scala has a Stream class that is very similar to the Clojure lazy sequence.

Here's a Scala version of the rrange function from 12.3:

  def rrange(start: Int, end: Int): Stream[Int] =
    if (start > end) Stream.empty[Int]
    else
      start #:: rrange(start + 1, end)




Eric Pederson

unread,
Jan 5, 2013, 6:00:24 PM1/5/13
to fp...@googlegroups.com
Also, Scala has a whole set of immutable collection classes (besides Stream) that implement structural sharing.
Reply all
Reply to author
Forward
0 new messages