Appendix A. Exercise hints and tips
This appendix contains hints and tips to get you thinking in the right direction for the more challenging exercises in this book. Trivial exercises have been omitted from this appendix, but full solutions for all exercises can be found in appendix B.
A.1 Chapter 3: Functional data structures
Exercise 3.1
Try matching on the list’s element type. Consider carefully how you would deal with an empty list.
Exercise 3.2
The same applies here as for exercise 3.1.
Exercise 3.3
Use matching and recursion to solve this problem. Consider all the following scenarios in your solution:
-
What should the function do if the
n
argument is0
? -
What should it do if the list is empty?
-
What if the list is not empty and ...
Get Functional Programming in Kotlin 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.