CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 20: Tree Recursion.

Slides:



Advertisements
Similar presentations
Class 21: Imperative Programming University of Virginia cs1120 David Evans.
Advertisements

Lisp II. How EQUAL could be defined (defun equal (x y) ; this is how equal could be defined (cond ((numberp x) (= x y)) ((atom x) (eq x y)) ((atom y)
Lisp II. How EQUAL could be defined (defun equal (x y) ; this is how equal could be defined (cond ((numberp x) (= x y)) ((atom x) (eq x y)) ((atom y)
4 Kinds of Sentences and the end mark flow.
OR Writing Great Paragraphs
The 3.8 Paragraph OR Writing the No-Hassle Way. Introduction: v 1 topic v 3 points v 8 sentences The 3.8 Paragraph is made up of.
Combinations. Objectives: I can predict and find the number of combinations that can be made from a given number of options I can make a tree diagram.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 4: Review Conditional & Word Stuff.
Helper functions: when extra arguments are needed Consider this problem: we want a function index_items that takes a list L and gives a number to each.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 17: HOF and Tick-Tack-Toe.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 18: HOF.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 26: Printing and Stuff.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 14: Number Spelling Mini-project.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 12: Homework stuff and Accumulating Recursion.
Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 19: HOF Problems.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 6: Mini-Project Prep.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 10: Recursion Rocks Again!
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 13: Bugs and Two Stage Recursion.
6.001 SICP SICP Sections 5 & 6 – Oct 5, 2001 Quote & symbols Equality Quiz.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 1: Introduction & Administration.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 11: Accumulating Recursion.
Feb 28More complicated recursions March 7Tree recursion, etc. Number-spelling Miniproject (#2) March 14Higher order procedures March 21Spring Break March.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 8: Recursion.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 9: Recursion Rocks!
CS 3 Final Review Gilbert Chou, Jenny Franco and Colleen Lewis December 14, pm GPB.
Symbolic Expressions (S Expressions) Syntax: Opening and Closing parenthesis having elements in between. List represented in LISP: (A B2 C3 Shahid) (A.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 2: Review – Writing Procedures.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 16: Let and Lambda.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 25: Trees and Generalized Lists.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 27: Review – most children and truth about cons.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 7: Review.
SchemeCOP Introduction to Scheme. SchemeCOP Scheme Meta-language for coding interpreters –“ clean ” semantics Scheme = LISP + ALGOL –simple.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 15: Procedures as Arguments.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 5: Difference Between Dates Case Study.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 24: Review for lists, map and member.
CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 3: Conditional Expressions.
Cs1120 Fall 2009 David Evans Lecture 20: Programming with State.
American Ice Cream Flavors In this presentation you will get an overview of the best American ice cream flavors. So, sit back and enjoy...
2 nd Grade: Line Goal: Students will create ice cream themed projects in order to demonstrate an understanding of outline and water color techniques.
The Fast Food Game How much do you know about American’s favorite fast foods?
Recitation 7: Data Abstraction II 28 Feb 2007 RI: Gerald Dalley Announcements Solutions, handouts, etc.:
Creating Graphs Or, How to show your results so that others can understand.
What can you do to make a word problem easier to understand? For example: Mrs. Dawson has 8 blue marbles and 6 green marbles in a bag. She puts in 7 more.
KOOL KAKEZ CREATED BY THE DISCOVER TEAM. HERE ARE THE 30 COMBINATIONS OF CAKES YOU CAN BUY!
Making Graphs and Understanding Data Grade 1 Math.
Our Important Book By Ms. Ray’s Class. Introduction Welcome to Our Important Book. This book tells you about the people, places, and things that are important.
Summer Spring Winter Fall Summer Spring Ice Cream Sundae  You get to chose on what toppings you would like on it  it’s only $2.99.
Creating Graphs. Where Does the Information Come From? A question is asked. A question is asked. What kind of ice cream does everyone like in our class?
CS61A Lecture Colleen Lewis. Clicker poll Where do you think you’re learning the most? I assume you’ll learn the most in lab & disc (so.
CS61A Lecture Colleen Lewis. Clicker poll How do you feel about the “talk to your neighbor” stuff during lecture A)Like it B)It is okay.
The 3.8 Paragraph OR Writing the No-Hassle Way. Introduction: v 1 topic v 3 points v 8 sentences The 3.8 Paragraph is made up of.
CS61A Lecture Colleen Lewis. Clicker poll Do you feel comfortable posting questions to piazza? A)Yes with my classmates and instructors.
By Samantha runston My favorite color is blue!  Its so cute.
How to Write the Five Paragraph Essay Remember the basic structure of a paragraph?
Acrostic Poems.
Racket CSC270 Pepper major portions credited to
Mint Chip Mint Chip Mint Chip Mint Chip Mint Chip Mint Chip Mint Chip
Lecture 8: Recursion Practice CS200: Computer Science
Cookie Dough Cookie Dough Cookie Dough Cookie Dough Cookie Dough
Lecture 15: Tables and OOP
Lecture #8 מבוא מורחב.
Lecture 16: Tables and OOP
Explicit Application of Procedures, and Explicit Evaluation
List and list operations (continue).
6.001 SICP Interpretation Parts of an interpreter
Lecture # , , , , מבוא מורחב.
Cat.
Malt Amore Malt Amore Malt Amore Malt Amore Malt Amore Malt Amore
Zanzimint Zanzimint Zanzimint Zanzimint Zanzimint Zanzimint Zanzimint
Presentation transcript:

CS3L: Introduction to Symbolic Programming Summer 2008Colleen Lewis Lecture 20: Tree Recursion

Today Lists Lists vs sentences List Append Cons Trial by error coding = bad

Ice cream flavors I want to list ice cream flavors (chocolate mint chip mocha almond fudge) (chocolate (mint chip) (mocha almond fudge)) This is a list! Here is how it was created: ( list ‘chocolate ‘(mint chip) ‘(mocha almond fudge))

lists vs sentences Sentences can be made of words/numbers Lists can have be made of words/numbers sentences #f or #t procedures other lists!!!

sentence Examples (se ‘cat ‘dog)  ‘(cat dog) (se ‘(cat) ‘(dog))  ‘(cat dog) (se ‘cat ‘(dog))  ‘(cat dog) (se ‘(cat) ‘dog)  ‘(cat dog) (se ‘cat ‘())  ‘(cat) (se ‘() ‘dog)  ‘(dog)

accessors sentence & word stuff list stuff firstcar butfirstcdr last  Butlast 

other procedures sentence & word stuff list stuff empty?null? sentence?list? itemlist-ref sentencelist

Takes any number of arguments and puts them in a list

list Examples (list ‘cat ‘dog)  ‘(cat dog) (list ‘(cat) ‘(dog))  ‘((cat) (dog)) (list ‘(cat) ‘dog)  ‘((cat) dog) (list ‘cat ‘(dog))  ‘(cat (dog)) (list ‘cat ‘())  ‘(cat ()) (list ‘() ‘dog)  ‘(() dog) (list ‘(cat ()) ‘dog)  ‘((cat ()) dog)

cons Takes two arguments Makes the first arg the car of the new list Makes the second arg the cdr of the new list The second argument MUST be a list

cons Examples (cons ‘cat ‘( dog ))  ‘(cat dog) (cons ‘(cat) ‘( dog ))  ‘((cat) dog) (cons ‘cat ‘())  ‘(cat) (cons ‘() ‘( () dog ))  ‘(() () dog) (cons ‘(cat) ‘dog  ‘((cat). dog)

append Takes two lists and turns them into one Both arguments MUST be lists

append Examples (append ‘(cat) ‘(dog))  ‘(cat dog) (append ‘(cat) ‘())  ‘(cat) (append ‘() ‘(dog))  ‘(dog) (append ‘(cat) ‘(()))  ‘(cat ()) (append ‘(()())‘(dog))  ‘(() () dog)

Trial by error coding

(define (pluralize L) (if (null? L) ‘() (cons (plural (car L)) (pluralize (cdr L)))))