CS3L: Introduction to Symbolic Programming - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

CS3L: Introduction to Symbolic Programming

Description:

(ice (bake (make-batter x))) (define (bake x) (you baked)) Prepare ... Bake the Cake. Heat oven. Put cake in oven. Close door. Prepare the cooked Cake. Let cool ... – PowerPoint PPT presentation

Number of Views:72
Avg rating:3.0/5.0
Slides: 12
Provided by: collee2
Category:

less

Transcript and Presenter's Notes

Title: CS3L: Introduction to Symbolic Programming


1
CS3L Introduction to Symbolic Programming
Lecture 4 Review Conditional Word Stuff
  • Summer 2008 Colleen Lewis
  • colleenL_at_berkeley.edu

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

3
Something well 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 ltpredicategt
  • lttrue casegt ltfalse casegt)
  • (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
Write a Comment
User Comments (0)
About PowerShow.com