This project holds all my exercise answers to the book Functional Programming in Scala.
The MOST IMPORTANT difference between my repo and the official one is that my repo HAS test cases for most of the exercises.
You may find the ebook here.
.
├── build.sbt
├── doc
│ └── fpinscala.pdf
├── LICENSE
├── project
│ └── plugins.sbt
├── README.md
├── scalastyle-config.xml
└── src
├── main
│ ├── java
│ ├── resources
│ └── scala
│ └── fpinscala
│ ├── examples
│ │ └── ch02gettingstarted
│ │ └── GettingStarted.scala
│ └── exercises
│ └── ch02gettingstarted
│ └── GettingStarted.scala
└── test
├── java
├── resources
└── scala
└── fpinscala
└── exercises
└── ch03datastructures
└── ListSuite.scala
19 directories, 8 files
All the exercise answers are included in src/main/scala/fpinscala/
,
while the test code are put in src/test/scala/fpinscala/
.
ScalaTest is used in the test cases. So after finish the exercises code, you may add the test cases in the test directory to check if your answer is right.
When you are working on the exercises, the steps might be the followings:
sbt ~scalastyle # To check if the code style are all correct
sbt ~test # To check if all the test cases passes
Here is a snapshot of my workspace in Vim with tmux enabled.
Exercise answer code in upper left part, and test code in upper right,
while the lower left is an area for running sbt ~test
and sbt ~scalastyle
in the lower right.
Here is my tmux session config:
new -s fpinscala -n terminal
neww -n dev 'vim; zsh'
splitw -v -p 20 -t 0 bash -c 'sbt ~test'
splitw -h -p 50 -t 1 bash -c 'sbt ~scalastyle'
selectw -t 1
selectp -t 0
And you may refer to my blog and github for detail.
IntelliJ IDEA is powerful IDE for many programming languages. You would probably like to use it as your main IDE.
This project can be opened in IDEA directly.
This project uses scalastyle by adding the plugin config in project/plugins.sbt
. The style config file used in this project is from Spark. If you do not like the spark code style, you may generate a new style config file yourself by sbt scalastyleGenerateConfig
. And after that, you can check the code style by running sbt scalastyle
.