Exercises

The following exercises are designed to test your knowledge of the Scala programming language. They cover the content presented in this chapter, along with some additional Scala features. The last two exercises contrast the difference between concurrent and distributed programming, as defined in this chapter. You should solve them by sketching out a pseudocode solution, rather than a complete Scala program.

  1. Implement a compose  method with the following signature:
                def compose[A, B, C]
                (g: B => C, f: A => B): A => C = ??? 
    

    This method must return a function h, which is the composition of the functions f and g

  2. Implement a fuse method with the following signature:
                def fuse[A, B] 
                (a: Option[A], b: Option[B]): Option[(A, B)] = ??? 
    

    The resulting ...

Get Learning Concurrent Programming in Scala - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.