1 / 10

100 likes | 241 Views

GBK Programming 1. Jordan Johnson. Today’s plan. Greeting Review cond Lesson : movement in two dimensions Homework Clean-up. Cond -expressions. ( cond …). Problem.

Download Presentation
## GBK Programming 1

**An Image/Link below is provided (as is) to download presentation**
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.
Content is provided to you AS IS for your information and personal use only.
Download presentation by click this link.
While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

**GBK Programming 1**Jordan Johnson**Today’s plan**Greeting Review cond Lesson: movement in two dimensions Homework Clean-up**Cond-expressions**(cond …)**Problem**Develop the function sign that takes a number and returns its sign (-1 for negative numbers, 1 for positive numbers, 0 for 0).**Problem**(define W 200) (define H 300) Suppose we’rewriting pong: Develop the function ball-state that takes the ball’s x-coordinate and returns “play” if the ball is onscreen, “L” if the ball has gone off the left side, “R” if it’s gone off the right side.**Movement in 2-D**• So far, our worlds are simple: • a number • a string • Pong requires 2 dimensions… • …and for that we need posns.**posns: points in 2-space**• A posn is a (make-posnnumbernumber)where the numbers together represent an x- and y-coordinate pair. • e.g., (3, 7) would be (make-posn3 7) • Laws of posns: • (posn-x (make-posna b)) a • (posn-y (make-posna b)) b**posn functions**make-posn is the posnconstructor. posn-x and posn-y are accessors or selectors. We also get posn?, which is a type predicate.**Homework**• Due Wednesday: HW on cond. • See web site.**Clean-up**• Before you leave, please . . . • Log out. • Push in your chair. • Make sure you’ve got everything. • Make sure all trash ends up in the trash can.

More Related