The Artima Developer Community
Sponsored Link

Programming in Scala Forum
book, reversing

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Andrew Gaydenko

Posts: 8
Nickname: anli
Registered: Dec, 2007

book, reversing Posted: Dec 26, 2007 10:34 PM
Reply to this message Reply
Advertisement
page 261:


1. def rev must be replaced with:

def rev[T](xs: List[T]): List[T] = xs match {
case List() => xs
case x :: xs1 => rev(xs1) ::: List(x)
}

2.

xs.reverse.init == xs.tail
xs.reverse.tail == xs.init

must be replaced with

xs.reverse.init == xs.tail.reverse
xs.reverse.tail == xs.init.reverse

Topic: How far can I expect to take implicit conversions? Previous Topic   Next Topic Topic: Calling super class constructor

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use