Lesson 8. Writing recursive functions

After reading lesson 8, you’ll be able to

  • See common patterns of applying rules of recursion
  • Understand how to use recursion on lists
  • Learn to time functions in GHCi
  • Reason about the edge cases of our five rules of recursion

The best way to get better at recursion is to practice, practice, practice! In this lesson, we’ll walk through a variety of recursive functions to help you apply the rules of recursion presented in the preceding lesson. As you do this, you’ll start to see that a few patterns repeat when solving recursive problems. Because Haskell doesn’t allow you to “cheat” by using stateful iteration, nearly all the code you write in Haskell will involve some recursion (though often this is abstracted ...

Get Get Programming with Haskell now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.