Skip to content

Latest commit

 

History

History
41 lines (28 loc) · 1.23 KB

08_recursion.md

File metadata and controls

41 lines (28 loc) · 1.23 KB

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