Scala for the Impatient: Chapter 4 exercises solutions

I’ve started going through the book: Scala for the Impatient by Cay Horstmann. I’m posting the solution to chapter 4 exercises below.

Advertisements

5 thoughts on “Scala for the Impatient: Chapter 4 exercises solutions

  1. Param

    Thanks for providing your solutions to the exercises in Scala for the Impatient. I have benefited from looking at your answers. Most of the time we solved the problem in the same way. Sometimes you solved it much more elegantly than I did. Only occasionally I solved it more elegantly than you did.

    Nice work!

    • Scala doesn’t accept this when I tried it.

      scala> def lteqgt(values: Array[Int], v: Int) = (values.count(_v))
      :17: error: not found: value _v
      def lteqgt(values: Array[Int], v: Int) = (values.count(_v))

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s