Functional Problem Solving (CSC 151 2015S) : EBoards

CSC151.01 2015S, Review Session 2: Starting Scheme


Overview

Admin

Your Questions

My Questions

Sample Quiz Questions

Question type one: "Draw the picture"

Consider the following sequence of definitions

    (define d1 (hshift-drawing 50 drawing-unit-circle))
    (define d2 (hshift-drawing 20 drawing-unit-square))
    (define d3 (scale-drawing 5 (drawing-group d1 d2)))
    (recolor-drawing d2 "red")
    (define d4 (scale-drawing 20 d1))
    (image-show (drawing->image (drawing-group d3 d4) 100 50))

Sketch the result

Question type two: "Compute this value"

The "simple geometric center" of a drawing is the point horizontally midway between the left edge and the right edge of the drawing, and vertically midway between the top edge and the bottom edge of the drawing. Recall that there is no drawing-bottom or drawing-right procedure. Sketch the code you would use to find the x coordinate of the center of drawing my-drawing. (You don't know the definition of that drawing.)

(define center-x
  (+ (/ (drawing-width my-drawing) 2)
     (drawing-left my-drawing)))