This document provides an overview of functional programming concepts in Scala including:
1. Referential transparency and immutability which help enable reliable, concurrent programs.
2. Traversal and mapping of data structures in a lazy and composable way using applicative functors.
3. Using reducers for parallel composition and aggregation in a simple way.
4. Representing hierarchical data as trees and providing utilities for traversing trees.
5. Exceptions and configuration as first-class parts of the program flow.
3. tour
import IncredibleStringReverser._
class ReverserSpec extends Specification {
"a reversed empty string must be empty" in {
reverse("") must_== ""
}
"a reversed empty string must really *be empty*" in {
reverse("") must be empty
}
"a reversed string must be reversed abc -> cba" in {
reverse("abc") must be_==("cba")
}
"a longer string must also be reversed. Whoops!" in {
reverse("abcdef") must be_==("xxxxx")
}
}