4. Functional Programming in Scala
1.1 FP Concepts: Pure Function
A function of type A => B maps
every value of type A to exactly
one value of type B
And does nothing else
“Nothing else” = Side effects: Modifying a data structure,
setting a field on a object, throwing an exception,
printing to the console, reading from or writing to a file
1 WHY FP?
5. Functional Programming in Scala
1.1 FP Concepts: Referential transparency
1 WHY FP?
If you have an expression, this expression is RT if you can evaluate
it and then replace this expression with the value that you get
A function is pure if f(x) is RT when x is RT
6. Functional Programming in Scala
1.1 FP Concepts: Scala is not a purely functional language!!
1 WHY FP?
22. Functional Programming in Scala
2.1 Mutability vs Immutability
2 FP IN SCALA: THE BASICS
All the classes that mix-in this trait should be in this file
A is covariant
23. Functional Programming in Scala
2.1 Mutability vs Immutability
2 FP IN SCALA: THE BASICS
Variadic function syntax
Tail call annotation