Administrivia - PowerPoint PPT Presentation

1 / 11
About This Presentation
Title:

Administrivia

Description:

If you need a regrade, see the person that graded that question ... (sprite sprat spring sprong site sat sing. song kite kat king kong) ... – PowerPoint PPT presentation

Number of Views:22
Avg rating:3.0/5.0
Slides: 12
Provided by: natetit
Category:

less

Transcript and Presenter's Notes

Title: Administrivia


1
(No Transcript)
2
Midterm 1
  • You did great
  • If you need a regrade, see the person that graded
    that question
  • Solutions available on the portal soon.

3
Schedule
Feb 28 Midterm 1
March 7 Tree recursion, etc. Number-spelling Miniproject
March 14 Higher order procedures
March 21 Spring Break
March 28 More HOF Lists! (instead of sentences and words)
April 4 Recursion (advanced)
April 11 Midterm 2
4
Number Spelling
  • Read Simply Scheme, page 233, which has hints
  • Another hint (principle) don't force
    "everything" into the recursion.

5
Problem find all the even numbers insentence of
numbers
  • (define (find-evens sent)
  • (cond ( base case
  • )
  • ( rec case 1 odd
  • )
  • ( rec case 2 even
  • )
  • ))

(define (find-evens sent) (cond ((empty? sent)
base case '() )
((odd? (first sent)) rec case 1
(find-evens (bf sent)) ) (else
rec case 2 even (se (first sent)
(find-evens (bf sent))) ) ))
6
gt (find-evens '(2 3 4 5 6))
sent ( 2 3 4 5 6 )
(se 2
sent ( 3 4 5 6 )
sent ( 4 5 6 )
(se 4
sent ( 5 6 )
sent ( 6 )
(se 6
sent ( )
()
  • (se 2 (se 4 (se 6 ())
  • (2 4 6)

7
Why is recursion hard?
  • ONE function
  • replicates itself,
  • knows how to stop,
  • knows how to combine the replications
  • There are many ways to think about recursion you
    absolutely do not need to understand all of them.
  • Knowing recursion WILL help with all sorts of
    ways while programming, even if you dont often
    use it.

8
Recursive patterns
  • Most recursive functions that operate on a
    sentence fall into
  • Mapping square-all
  • Counting count-vowels, count-evens
  • Finding member, first-even
  • Filtering keep-evens
  • Testing all-even?
  • Combining sum-evens

9
What recursions arent covered by these patterns?
  • Weird ones like reverse, or downup
  • Ones that dont traverse a single sentence
  • E.g., mad-libs takes a sentence of replacement
    words e.g., (fat Henry three) and a sentence
    to mutate e.g., (I saw a horse named
    with legs)
  • Tree recursion multiple recursive calls in a
    single recursive step

10
Advanced recursion
  columns (C)   columns (C)   columns (C)   columns (C)   columns (C)   columns (C)   columns (C)   columns (C)
rows(R) 0 1 2 3 4 5 ...
rows(R) 0 1           ...
rows(R) 1 1 1         ...
rows(R) 2 1 2 1       ...
rows(R) 3 1 3 3 1     ...
rows(R) 4 1 4 6 4 1   ...
rows(R) 5 1 5 10 10 5 1 ...
rows(R) ...  ... ... ... ... ... ... ...
Pascals Triangle
  • How many ways can you choose C things from R
    choices?
  • Coefficients of the (xy)R look in row R
  • etc.

11
pair-all
  • Write pair-all, which takes a sentence of
    prefixes and a sentence of suffixes and returns a
    sentence pairing all prefixes to all suffixes.
  • (pair-all (a b c) (1 2 3)) ? (a1 b1 c1 a2 b2
    c2 a3 b3 c3)
  • (pair-all (spr s k) (ite at ing ong)) ?(sprite
    sprat spring sprong site sat sing song kite kat
    king kong)
Write a Comment
User Comments (0)
About PowerShow.com