The Road to Functional Programming

Educational material to learn functional programming in Scala, from scratch, in a structured and comprehensive way.

View project on GitHub

Recursion

Solves the lack of loops

Recursion is the equivalent of induction reasoning

https://yourbasic.org/algorithms/induction-recursive-functions/

Examples: list length, take nth element, flatten list, map, flatMap

Tail recursion. But it doesn’t solve all problems

Recursion from two different functions

Exercises 5.1

5.1.1

Implements the functions with the following definitions:

def f[A](as: List[List[A]]): List[A]
def g[A, B](as: List[A], f: A => List[B]): List[B]
def h[A, B](as: Option[A], f: A => Option[B]): Option[B]

References