Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Class 13: Loopy Recursive Functions

David Evans
February 22, 2016

Class 13: Loopy Recursive Functions

cs1120: Introduction to Computing
Explorations in Language, Logic, and Machine
University of Virginia, Spring 2016

http://xplorecs.org/class13

Class 13:
Loops and Recursive Functions
Hamming Distance
Edit Distance
Copying Lists

David Evans

February 22, 2016
Tweet

More Decks by David Evans

Other Decks in Programming

Transcript

  1. Class 13: Loopy Recursive Functions Introduction to Computing: Explorations in

    Language, Logic, and Machines cs1120 Spring 2016 David Evans University of Virginia
  2. Menu Recursive Functions vs. Loops Hamming Distance Edit Distance Copying

    Lists (Flattening!) Practice programming with lists and recursive functions!
  3. “If you want a short answer, it’s simply unpythonic.” Guido

    van Rossum (Python’s Benevolent Dictator for Life) (blog post on Tail Recursion Elimination)
  4. Why You Should be Comfortable with Recursive Definitions (even if

    they are never really necessary and not encouraged in Python): 1. Learning to think, not learning to program. Recursive definitions are great tools for thinking. 2. Learning to program, not learning to Python. Ways to describe computations, not just what works best in Python. 3. Even in Python, more complex programs that operate on recursive data are best as recursive functions.
  5. Levenshtein Distance edit_distance(a, b) = The minimum number of insert,

    delete, and mutate operations needed to transform a into b. Does it matter if the definition is a into b or b into a?
  6. Charge Return Project 2: – Gold star: Congratulations! Orange Belt

    – Green star: Read notes for how to earn Orange Belt – No star: make sure to talk to or email me (if you haven’t already)