recursion.md

November 4, 2020 ยท View on GitHub

Recursion

The Concept

The ability to define a function that calls itself, see recursion

What to cover

  • What is recursion? Wwhat is recursion? When should it be used?
  • What forms or recursion are supported?: Are recursive functions supported? Recursive types? Does the language supports tail recursion?
  • Using recursion: How can recursive functions/types be defined?

Exercises

Ordering pizzas

This exercise handles ordering pizzas. The reference implementation (F#) teaches:

  • Know what recursion is.
  • Know how to define a recursive function.
  • Know how to define a recursive type.
  • Know how to write a tail-recursive function.
  • Know how to recursively process lists.

Implementations

TrackExerciseChanges
F#recursionNone
JavaScriptrecursionAllow for multiple extra topping, or extra sauces, don't use pattern matching but list destructuring & iteration