Menu

Tree [5b36f1] master /
 History

HTTPS access


File Date Author Commit
 answerkey 2014-11-22 Daniel Wright Daniel Wright [ff3419] Initial commit
 answers 2014-11-22 Daniel Wright Daniel Wright [ff3419] Initial commit
 exercises 2014-12-31 dwwright1987 dwwright1987 [5b36f1] Chapter 6 exercises 1-10
 project 2014-11-22 Daniel Wright Daniel Wright [ff3419] Initial commit
 .gitignore 2014-12-01 dwwright1987 dwwright1987 [4c8717] chapter 2 exercises solutions
 LICENSE 2014-11-22 Daniel Wright Daniel Wright [ff3419] Initial commit
 README.md 2014-11-22 Daniel Wright Daniel Wright [ff3419] Initial commit
 sbt 2014-11-22 Daniel Wright Daniel Wright [ff3419] Initial commit
 sbt-launch.jar 2014-11-22 Daniel Wright Daniel Wright [ff3419] Initial commit
 sbt.bat 2014-11-22 Daniel Wright Daniel Wright [ff3419] Initial commit
 sbt.cmd 2014-11-22 Daniel Wright Daniel Wright [ff3419] Initial commit

Read Me

This repository contains exercises, hints, and answers for the book Functional Programming in Scala. Along with the book itself, it's the closest you'll get to having your own private functional programming tutor without actually having one.

Here's how to use this repository:

Each chapter in the book develops a fully working library of functions and data types, built up through a series of exercises and example code given in the book text. The shell of this working library and exercise stubs live in exercises/src/main/scala/fpinscala/<chapter-description>, where <chapter-description> is a package name that corresponds to the chapter title (see below). When you begin working on a chapter, we recommend you open the exercise file(s) for that chapter, and when you encounter exercises, implement them in the exercises file and make sure they work.

If you get stuck on an exercise, let's say exercise 4 in the chapter, you can find hints in answerkey/<chapter-description>/04.hint.txt (if no hints are available for a problem, the file will just have a single '-' as its contents) and the answer along with an explanation of the answer and any variations in answerkey/<chapter-description>/04.answer.scala or 04.answer.markdown. The finished Scala modules, with all answers for each chapter live in answers/src/main/scala/fpinscala/<chapter-description>. Please feel free to submit pull requests for alternate answers, improved hints, and so on, so we can make this repo the very best resource for people working through the book.

Chapter descriptions:

  • Chapter 2: gettingstarted
  • Chapter 3: datastructures
  • Chapter 4: errorhandling
  • Chapter 5: laziness
  • Chapter 6: state
  • Chapter 7: parallelism
  • Chapter 8: testing
  • Chapter 9: parsing
  • Chapter 10: monoids
  • Chapter 11: monads
  • Chapter 12: applicative
  • Chapter 13: iomonad
  • Chapter 14: localeffects
  • Chapter 15: streamingio

To build the code for the first time, if on windows:

$ .\sbt.cmd

If on mac/linux:

$ chmod a+x ./sbt
$ ./sbt

This will download and launch sbt, a build tool for Scala. Once it is finished downloading, you'll get a prompt from which you can issue commands to build and interact with your code. Try the following:

> project exercises
> compile

This switches to the exercises project, where your code lives, and compiles the code. You can also do:

> console

to get a Scala REPL with access to your exercises, and

> run

To get a menu of possible main methods to execute.

All code in this repository is MIT-licensed. See the LICENSE file for details.

Have fun, and good luck! Also be sure to check out the community wiki for the chapter notes, links to more reading, and more.

Paul and Rúnar

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.