Lesson 21: set! and Tail Recursion

Outline:

  1. Special form: set!
    • evaluating set!
    • set! vs. define
  2. Tail-call optimization
    • what it is
    • why it’s useful
    • recognizing tail recursion
  3. Wrap-up

What’s next

Upcoming events/assessments:

  • CS Bits and Bytes Thursday at 3:30pm in Anderson 329
  • Interpreter Parts 4+5 cannot be resubmitted after next Monday at 10pm
  • Exam Day 2 will be this Friday (includes Quiz 6 and all other LOs we’ve seen so far)

What you should do now:

Reading assignment (to be completed by the next class):

Tail calls (from today):

  • Tail calls – stop at “Tail recursion modulo cons”

For next time:

  • Read this opinion piece on why Python doesn’t have tail-call optimization (a.k.a. tail recursion elimination)