Ok, let us get the facts right. We have not provided solution to each exercise but the solutions that we have provided would be good for you to understand the concepts. It would also help you realize how efficiently we can use higher order functions in Scala.
The Structure and Interpretation of Computer Programs (http://mitpress.mit.edu/sicp/full-text/book/book.html) is a seminal book which helps you reason and understand the structure of computer programs. Though the book has been written a while back but the content is refreshingly applicable to the modern programming languages like Scala.
The github project, provides solutions to the following problems
* Exercise 1.5 and 1.6 at http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-10.html
* Exercise 1.10 at http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-11.html
* Exercises 1.34, 1.38, 1.41, 1.42 and 1.43 at http://mitpress.mit.edu/sicp/full-text/book/book-Z-H-12.html
Here, we reproduce a couple of problems.
As you would notice, this problem has a direct consequence with the way the evaluation is done. There is a difference between the two approaches for applicative-order evaluation or normal-order evaluation.
Let us look at another example where we are composing functions
and the solution would look like
Once you are done with the above, there is a bonus question as well
To see the solution, visit our github repository. If you feel something is missing in tacking the questions do send us your feedback either as a comment to this post or send us a mail on email@example.com We have omitted the test cases and have used objects to keep the code simple and yet display our understanding. You could write simple ScalaTest cases instead of the println that you see in the code.