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

Class 10: Detecting Gravitational Waves, Progra...

David Evans
February 12, 2016

Class 10: Detecting Gravitational Waves, Programming with Lists

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

http://xplorecs.org/class10

Class 10:
Gravitational Waves
Making Triples from Pairs
Making Lists
Programming with Lists

David Evans

February 12, 2016
Tweet

More Decks by David Evans

Other Decks in Programming

Transcript

  1. cs1120 Spring 2016 David Evans University of Virginia Class 10:

    Programming with Data Introduction to Computing: Explorations in Language, Logic, and Machines
  2. Plan Making Lists from Pairs Programming with Lists Project 2

    is Due Monday: Good Project 2 is automatic Green Belt pass! Yuchi has scheduled extra office hours Sunday, 3-4:30pm (also has regular office ours today right after class) If you don’t complete Yellow Belt by Sunday, additional steps will be necessary.
  3. Multuples A Quintuple is a Pair where the second part

    is a Quadruple A Sextuple is a Pair where the second part is a Quintuple A Septuple is a pair where the second part is a Sextuple An Octuple is group of octupi A ? is a Pair where the second part is a …? 15
  4. Lists List ::= Element List 16 A List is a

    Pair where the second part is a List. One big problem: how do we stop? This only allows infinitely long lists!
  5. Lists List ::= Element List List ::= 17 A List

    is either: a Pair where the second part is a List or, empty It’s hard to write this!
  6. Null List ::= Element List List ::= 18 A List

    is either: a Pair where the second part is a List or, empty (None) None None here is like ε for BNF grammars!
  7. Recursive Procedures on Lists 1. Be very optimistic! 2. Determine

    the base case: smallest version of the problem, where you know the answer right away 3. Recursive case: combine the result of doing something with the first element, with the recursive call on the rest of the list
  8. Charge • Project 2 is due Monday • We are

    focusing on recursive ways to define functions now because they are general, universal, and elegant – But, not the “Pythonic” way to do things…we will see other ways to define these same functions