SlideServe
Menu
Préférences
© SlideServe · v2026

GBK Programming 1

helene avatar
10 diapositives · 267 Views · Oct 23, 2014

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

GBK Programming 1 - slide 1
01 / 10GBK Programming 1
1 / 17

Télécharger la présentation

GBK Programming 1
Une image / un lien ci-dessous est fourni (tel quel) pour télécharger la présentation

Politique de téléchargement : le contenu du site vous est fourni TEL QUEL pour votre information et votre usage personnel ; il ne peut être vendu, concédé sous licence ni partagé sur d’autres sites sans l’accord de son auteur.Le contenu vous est fourni TEL QUEL, pour votre information et votre usage personnel uniquement. Téléchargez la présentation en cliquant sur ce lien. Lors du téléchargement, si vous ne parvenez pas à télécharger une présentation, l’éditeur a peut-être supprimé le fichier de son serveur.Pendant le téléchargement, si vous ne parvenez pas à obtenir une présentation, le fichier a peut-être été supprimé par l’éditeur.

F I N

Plus de contenu associé

Transcription de la présentation
  1. GBK Programming 1 Jordan Johnson

  2. Today’s plan Greeting Review cond Lesson: movement in two dimensions Homework Clean-up

  3. Cond-expressions (cond …)

  4. Problem Develop the function sign that takes a number and returns its sign (-1 for negative numbers, 1 for positive numbers, 0 for 0).

  5. 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.

  6. Movement in 2-D • So far, our worlds are simple: • a number • a string • Pong requires 2 dimensions… • …and for that we need posns.

  7. 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

  8. 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.

  9. Homework • Due Wednesday: HW on cond. • See web site.

  10. 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.