1 / 11

CS3L: Introduction to Symbolic Programming

CS3L: Introduction to Symbolic Programming. Summer 2008 Colleen Lewis colleenL@berkeley.edu. Lecture 4: Review Conditional & Word Stuff. Today. Review Words and Sentences Review Conditionals Helper Procedures. Something we’ll see a lot of….

floydrose
Download Presentation

CS3L: Introduction to Symbolic Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS3L: Introduction to Symbolic Programming Summer 2008 Colleen Lewis colleenL@berkeley.edu Lecture 4: Review Conditional & Word Stuff

  2. Today • Review Words and Sentences • Review Conditionals • Helper Procedures

  3. Something we’ll see a lot of… • Constructors: procedures to make a piece of data • word and sentence • Selectors: procedures to return parts of that data piece • first, butfirst, etc.

  4. Sentence and Word Selectors • These work on sentences and words • butfirst • give you a sentence (for sentence) • give you a word (for a word) • butlast • give you a sentence (for sentence) • give you a word (for a word) • first • give you a word (always) • last • give you a word (always)

  5. Sentence and Word Selectors • These work on sentences and words • butfirst • give you a sentence (for sentence) • give you a word (for a word) • butlast • give you a sentence (for sentence) • give you a word (for a word) • first • give you a word (always) • last • give you a word (always)

  6. IF & COND Statements (if <predicate> <true case> <false case>) (cond (predicate1 return_expression1) (predicate2 return_expression2) (else return_expression3))

  7. and, or and not and - true only if all are true or - true if any are true not - true only if the one argument is false.

  8. Helper Procedures • Help make complicated programs simple • Believe • Make a cake • Prepare the cake batter • Bake the cake • Ice the cake (define (make-cake x) (ice (bake (make-batter x))) (define (bake x) ‘(you baked))

  9. Prepare the cake batter • Get Bowl • Get Beater • Get Ingredients • Measuring cups • Electricticity • Get bowl • Get ingredients • Stir

  10. Bake the Cake • Heat oven • Put cake in oven • Close door

  11. Prepare the cooked Cake • Let cool • Remove from pan • Ice it

More Related