Presentation is loading. Please wait.

Presentation is loading. Please wait.

Two dataflow diagrams. Program as recipe A program is a description of a computation It’s like a recipe Tells out to make an output (food) From inputs.

Similar presentations


Presentation on theme: "Two dataflow diagrams. Program as recipe A program is a description of a computation It’s like a recipe Tells out to make an output (food) From inputs."— Presentation transcript:

1 two dataflow diagrams

2 Program as recipe A program is a description of a computation It’s like a recipe Tells out to make an output (food) From inputs (ingredients) Through a series of operations (Some of which may be other recipes) Okay, so what are computations like?

3 Computation Computations have inputs and outputs Inputs are also known as arguments or parameters Outputs are also known as results or return values inputoutput

4 Computation as call and response Procedures are “called” with their inputs And “respond” with their return values inputoutput

5 Computation as transformation It’s often useful to think of the computation as transforming the input into the output Photoshop turns images into brighter/darker/funkier images WinAmp turns the CD representation of sound (sound amplitudes) into the MP3 representation of sound (sound spectra) inputoutput

6 Computation as transformation Many computations are cascaded transforms Netscape turns A mouse click into A link to follow, into An HTML file, into Colors for the pixels on the screen

7 The Pythagorean Theorem Pythagoras proved The square of the long side of a right triangle Has the same area as the squares of the two other sides together Gives us a way of computing the distance between points Given their coordinates

8 Computing distance Use coordinates to represent points on the screen Horizontal distance from corner Vertical distance from corner We can set up a triangle to compute the distance between two points The difference along each axis gives us a side Hypotenuse is the distance between the points So the distance squared is the sum of the squares of the differences in coordinates (6.27, 4.66) (8.63, 3.02) 4.66-3.02 = 1.64 8.63-6.27 = 2.36 √(2.36 2 + 1.64 2 ) = 2.87

9 Computation as flow Computations can have multiple inputs The patterns they form are more complicated than simple chains But they’re still networks of data flow x y x y − − n2n2 n2n2 +√n length start end line

10 Computation as flow Computations can have multiple inputs The patterns they form are more complicated than simple chains But they’re still networks of data flow x y x y − − n2n2 n2n2 +√n length start end line 0 0 1 1

11 Computation as flow Computations can have multiple inputs The patterns they form are more complicated than simple chains But they’re still networks of data flow x y x y − − n2n2 n2n2 +√n length start end line 0 0 1 1 1 1

12 Computation as flow Computations can have multiple inputs The patterns they form are more complicated than simple chains But they’re still networks of data flow x y x y − − n2n2 n2n2 +√n length start end line 0 0 1 1 1 1 1 1

13 Computation as flow Computations can have multiple inputs The patterns they form are more complicated than simple chains But they’re still networks of data flow x y x y − − n2n2 n2n2 +√n length start end line 0 0 1 1 1 1 1 1 2

14 Computation as flow Computations can have multiple inputs The patterns they form are more complicated than simple chains But they’re still networks of data flow x y x y − − n2n2 n2n2 +√n length start end line 0 0 1 1 1 1 1 1 2 1.414

15 Computation as flow Connection patterns can be tricky One output can feed many inputs A computation’s output can be one of its own inputs + delay sound

16 Computation as sequence Ultimately, computations are performed as a series of steps Programs implicitly define the sequence of steps But we avoid specifying the sequence directly Because it looses much of the structure of the problem Get the line’s start point Get its x coordinate Get the line’s end point Get its x coordinate Find the − 2 of the coordinates Get the line’s start point Get its y coordinate Get the line’s end point Get its y coordinate Find the − 2 of the coordinates Sum the two squared differences Take the square root


Download ppt "Two dataflow diagrams. Program as recipe A program is a description of a computation It’s like a recipe Tells out to make an output (food) From inputs."

Similar presentations


Ads by Google