Download presentation
Presentation is loading. Please wait.
1
four simple expressions in meta
2
Data objects Pieces of data in a computer are called objects Today, we’ll talk about four kinds of objects Numbers Pictures (images) Points (positions within an image) Procedures (programs) Take a set of objects as inputs (arguments) Return another object as a result Procedures are the most important kind of data in computer science
3
Referring expressions in English Phrases that refer to an object or objects “Robin” “Rob” “The TA of this class” “the grad students of Ian” “the people in 324” “France” “capitalism” “The sum of 2 and 3” “The mother of the TA of this class” We’ll focus on two kinds Names (“Robin”, “Rob”, “France”, “capitalism”) Functional expressions (the X of Y)
4
A deeply nested referring expression “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother of [the TA of [this class]]]]]]]] Please forgive the sexist expression “father of the nation”
5
Meaning follows form “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother of [the TA of [this class]]]]]]]] Please forgive the sexist expression “father of the nation”
6
Meaning follows form “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother of [the TA of [this class]]]]]]]]cs 395 Please forgive the sexist expression “father of the nation”
7
Meaning follows form “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother of [the TA ofRobin [this class]]]]]]]]cs 395 Please forgive the sexist expression “father of the nation”
8
Meaning follows form “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother of [the mother of [the grandfather of [the father of [the nation of [the mother ofRobin’s mom [the TA ofRobin [this class]]]]]]]]cs 395 Please forgive the sexist expression “father of the nation”
9
Meaning follows form “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother of [the mother of [the grandfather of [the father of [the nation ofThe United States [the mother ofRobin’s mom [the TA ofRobin [this class]]]]]]]]cs 395 Please forgive the sexist expression “father of the nation”
10
Meaning follows form “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother of [the mother of [the grandfather of [the father ofGeorge Washington [the nation ofThe United States [the mother ofRobin’s mom [the TA ofRobin [this class]]]]]]]]cs 395 Please forgive the sexist expression “father of the nation”
11
Meaning follows form “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother of [the mother of [the grandfather ofGeorge’s grandpa [the father ofGeorge Washington [the nation ofThe United States [the mother ofRobin’s mom [the TA ofRobin [this class]]]]]]]]cs 395 Please forgive the sexist expression “father of the nation”
12
Meaning follows form “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother of [the mother ofGeorge’s great grandma [the grandfather ofGeorge’s grandpa [the father ofGeorge Washington [the nation ofThe United States [the mother ofRobin’s mom [the TA ofRobin [this class]]]]]]]]cs 395 Please forgive the sexist expression “father of the nation”
13
Meaning follows form “The mother of the mother of the grandfather of the father of the nation of the mother of the TA of this class” [the mother ofGeorge’s great great grandma [the mother ofGeorge’s great grandma [the grandfather ofGeorge’s grandpa [the father ofGeorge Washington [the nation ofThe United States [the mother ofRobin’s mom [the TA ofRobin [this class]]]]]]]]cs 395
14
Referring expressions in meta Names (‘robin’, ‘rob’, ‘+’, ‘point’) Aka “variables” Refer directly to objects Constants (fixed names) Numbers Refer to fixed objects (the numbers) Strings “Arbitrary text enclosed in double-quotes” Also refer to fixed objects (the text) Functional expressions Sequences of expressions Separated by spaces (or line breaks) Enclosed in square brackets First expression has to refer to a procedure Example: [point 100 100]
15
Some functional expressions [box width height] A picture of a box with the specified width and height (which must be numbers) [ellipse width height] Same, but gives you a curved object instead of a box [line point point] A line with the specified endpoints [point number number] A point with the specified coordinates
16
Rectangles [box width height] Creates a rectangle Centered at (0,0) Width is width Height is height Default coloring Unfilled (interior is left alone) Border drawn in black (which shows up very poorly in these slides) ► [box 200 100] ►
17
hey stupid don’t you think it’s time you did an example?
18
Circles and ellipses [ellipse width height] Same, but curved If width and height are the same, you get a circle Otherwise, an ellipse ► [ellipse 200 100] ► [ellipse 100 100]
19
Lines [line start end] Makes a line from start to end Start and end are point objects Created using [point x y] Note that: Default is black line 1 pixel wide ► [line [point 0 0] [point 100 100]] ►
20
Coordinate system Positions on the screen described by (x, y) coordinates X: number of pixels to the right of the “origin” Y: number of pixels down from the “origin” Coordinates can be negative (system just shifts the image to make them visible) (0,0) (100, 33) (33, 100)
21
Groups [group object object …] Make a composite picture from multiple picture objects Objects can be shapes or other groups ► [group [box 100 100] [box 200 200] [box 300 300] [ellipse 100 100]] ►
22
hey how about another example?
23
Translate [translate point object object …] Shifts objects so that their (0,0) is now at point Shifting by [point 10 20] moves everything Right 10 pixels Down 20 pixels Also acts like a group, so you can include multiple objects and they’re all shifted ► [group [box 200 200] [translate [point 50 0] [box 100 100]]] ►
24
hey show them how to handle errors
25
that’s everything you need to know for the assignment but here’s some other stuff you might have fun with
26
Scaling [scale scale-factor object object …] Make a composite object from multiple picture objects Also acts like a group, so you can include multiple objects and they’re all scaled ► [box 100 100] ► [scale 2 [box 100 100] [box 10 10]] ►
27
Rotate [rotate angle object object …] Rotates contents clockwise angle degrees about the point (0,0) Also acts like a group, so you can include multiple objects and they’re all rotated around (0,0) ► [rotate 45 [box 100 100]] ►
28
Paint [paint color objects …] Fills interiors of objects with color, which can be A color object made with [color red green blue] A string (magic color name) A symbol (magic color name) The word: null (no quotes) Turns off filling Also acts like a group, so you can include multiple objects ► [group [box 200 200] [paint “black” [box 100 100]]] ►
29
Ink [ink pen objects …] [pen color width] Draws the outline of objects with specified pen Pen specifies color and width of line Pen objects can be created with the pen procedure … or you can just specify a color in lieu of a pen Also acts like a group, so you can include multiple objects ► [group [box 200 200] [ink [pen “black” 10] [box 100 100]]] ►
30
Peeking inside the data Objects are like web pages Pages can contain links to other pages Different from containing the pages themselves But I can in some sense pass you a whole set of pages by passing you a link to a single page that has links to the others Forming a group is like making a new web page with links to the component objects You can think of the components as “in” the group Or just as “available to” the group group ellipsebox
31
Data as hierarchy When we group objects inside groups inside other groups We get a tree- structured hierarchy Kind of like outlines And kind of like code group translatebox group translatebox group translatebox note: translate doesn’t actually change its arguments – it makes a translate object
Similar presentations
© 2024 SlidePlayer.com Inc.
All rights reserved.