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

Class 14: Flattening Practice

David Evans
February 24, 2016

Class 14: Flattening Practice

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

http://xplorecs.org/class14

Class 14:
Lists and Objects
Deep Copies
Flattening

David Evans

February 24, 2016
Tweet

More Decks by David Evans

Other Decks in Programming

Transcript

  1. Class 14: Flattening Practice Introduction to Computing: Explorations in Language,

    Logic, and Machines cs1120 Spring 2016 David Evans University of Virginia
  2. Menu Practice with Lists and Procedures! Orange Belt Promotion Directions

    will change (added problem) after Friday. Green Belt Promotion Automatic promotion from Project 3 extended to Monday.
  3. def list_copy(lst): """Returns a shallow copy of the input lst."""

    if not lst: return [] else: return [lst[0]] + list_copy(lst[1:]) p1 = [1, 2, 3] p2 = [p1, list_copy(p1)] p1.append(4) Python Tutor
  4. def list_copy(lst): """Returns a shallow copy of the input lst."""

    if not lst: return [] else: return [lst[0]] + list_copy(lst[1:]) p1 = [1, 2, 3] p2 = [p1, list_copy(p1)] p1.append(4) Python Tutor
  5. Charge Project 3: due Monday If you haven’t earned your

    Orange Belt yet, requirements will change after Friday!