CS3L: Introduction to Symbolic Programming - PowerPoint PPT Presentation

About This Presentation
Title:

CS3L: Introduction to Symbolic Programming

Description:

DO NOT CODE BEFORE YOU HAVE A PLAN! Put yours and your partners names and ... Make a Poster. Include Name of pattern. Description of the pattern. Example Code ... – PowerPoint PPT presentation

Number of Views:17
Avg rating:3.0/5.0
Slides: 11
Provided by: collee2
Category:

less

Transcript and Presenter's Notes

Title: CS3L: Introduction to Symbolic Programming


1
CS3L Introduction to Symbolic Programming
Lecture 14 Number Spelling Mini-project
  • Summer 2008 Colleen Lewis
  • colleenL_at_berkeley.edu

2
Adminstration
  • Number Spelling Mini-project 2
  • DUE Thursday at 1159 pm
  • Compress (Hwk12) occurs-in? (Hwk13)
  • DUE Tuesday at 1159 pm
  • Design your project before you start

3
Today
  • item instead of cond
  • Testing Framework
  • Tail vs. Embedded Recursion

4
Guideline Use item instead of cond
  • (define (get-day-name num)
  • (cond
  • ((equal? num 1) Sunday)
  • ((equal? num 2) Monday)
  • ((equal? num 3) Tuesday)
  • ((equal? num 4) Wednesday)
  • ((equal? num 5) Thursday)
  • ((equal? num 6) Friday)
  • ((equal? num 7) Saturday)))
  • (define (get-day-name num)
  • (item num (Sunday Monday Tuesday Wednesday
    Thursday Friday Saturday))

5
Testing Framework
  • (add-test-case
  • test-name
  • expected-return-value
  • scheme-expression)
  • (run-test-cases)
  • (clear-test-cases)

6
Random Administration
  • DO NOT CODE BEFORE YOU HAVE A PLAN!
  • Put yours and your partners names and logins on
    the top
  • You should be able to use scheme-gtsendBuffer
    without errors
  • 40 is spelled Forty
  • Please no ands

7
Tail versus embedded recursions
  • A tail recursion has no combiner, so it can end
    as soon as a base case is reached
  • Compilers can do this efficiently
  • An embedded recursion needs to combine up all the
    recursive steps to form the answer
  • The poor compiler has to keep track everything

8
Patterns in recursion (1-3 of 6)
  • Mapping
  • does something to every part of the input
    sentence
  • Counting
  • Counts the number of elements that satisfy a
    predicate
  • Finding
  • Return the first element that satisfies predicate
    (or, return rest of sentence)

9
Patterns in recursion (4-6 of 6)
  • Filtering
  • Keep or discard elements of input sentence
  • Testing
  • A predicate that checks that every or any element
    of input satisfies a test
  • Combining
  • Combines the elements in some way

10
Make a Poster
  • Include Name of pattern
  • Description of the pattern
  • Example Code
  • Examples of procedures that follow the pattern
Write a Comment
User Comments (0)
About PowerShow.com