This repository hosts my solutions to the exercises of the book Functional Programming in Scala, from Manning Publications.
The list of exercises and the official solutions can be found at https://github.com/fpinscala/fpinscala
You can find the examples at
src/main/scala
,
with a directory (Scala package) for each book chapter.
For each one of the exercises, I provide a test. Tests are
stored in the directory src/test/scala
, and you can reuse them for
your exercises.
You will need sbt to run the tests and compile the exercises.
To compile the exercises before running the tests, simply run
> compile
If it's the first time, it will download all the necessary dependencies (basically, the Scala Specs2 library).
To run all the tests, simply execute the following in sbt
> test
To run a specific test, execute
> testOnly chapXX.ExYYSpec
where XX
is the chapter number, and YY
is the exercise number. For
instance
> testOnly chap03.Ex10Spec
Some of the exercises can also be run as standalone applications.
To run the exercises in sbt, use
> runMain package_name.object_name args
For instance
> runMain chap2.Ex02 5
Not all exercises can be run as applications. To check the output for some input values of all the exercises, you can add cases to the tests.
All the code hosted in this repository is distributed under the MIT license. See the license for more details.