Functional Decomposition, Again - PowerPoint PPT Presentation

1 / 7
About This Presentation
Title:

Functional Decomposition, Again

Description:

Last Lecture. Lists of compound data can be useful. The type [[X]] The flatten function ... Today's Lecture. More on how to analyze problems. We've already seen ... – PowerPoint PPT presentation

Number of Views:27
Avg rating:3.0/5.0
Slides: 8
Provided by: csR7
Learn more at: https://www.cs.rice.edu
Category:

less

Transcript and Presenter's Notes

Title: Functional Decomposition, Again


1
Functional Decomposition, Again
2
Last Lecture
  • Lists of compound data can be useful
  • The type X
  • The flatten function
  • Using types to help us guess operations
  • The simplest recursive type is "Natural"
  • Patterns of induction
  • What can we compute with Natural?

3
Today's Lecture
  • More on how to analyze problems
  • We've already seen
  • Analyze data dependence
  • Make functions to capture such dependence
  • Analyze data organization
  • Define types to capture data organization
  • Today
  • Using case analysis
  • Creating auxiliary functions can be useful

4
A Simple Way to Sort
  • Sort X -gt X
  • Example
  • Given 3,5,4,2,1
  • Return 1,2,3,4,5
  • Example
  • Given 100,3,400
  • Return 3,100,400
  • Can we devise a Method for doing this?

5
Functional Decomposition
  • Small functions come up often
  • With Lists
  • append used in flatten, and many others
  • With Naturals
  • used in ,
  • used in exp, and
  • used in /
  • , -, exp all used in polynomials, linear
    algebra, and many others

6
Sorting
  • In class, we derived sort and insert
  • Recipe allowed us to derive both very
    systematically
  • (Code is same as in book)

7
All Possible Orderings
  • Example
  • Given 1,2,3
  • Return 1,2,3, 2,1,3, 2,3,1, 1,3,2,
    3,1,2, 3,2,1
  • Can the natural induction pattern help us figure
    out how to implement this function?
Write a Comment
User Comments (0)
About PowerShow.com