I've begun reviewing for the exam, and thankfully the course website is clearly organized and has tons of resources for me to check over. My plan is to begin reviewing from the last Test, then start at the beginning of the course and make my way to the middle. Obviously the early course material is not as complicated so that doesn't worry me too much. However, so far I've come across a couple questions:
While reviewing the Winter 2015 test, this question:
Question 3. [9 marks] Part (a) [4 marks] Show the result values of each of the following expressions [except the require and deļ¬nitions]. Recall: the color struct has its components in the order: RED GREEN BLUE ALPHA. The maximum value a component can have is 255.
(require picturing-programs) (define S (square 4 "solid" "blue"))
(length (image->color-list S))
Looking at the question, I assumed the answer would be 4 to account for RED GREEN BLUE ALPHA. But when I went to check in Racket, I got this:
> (require picturing-programs)
> (define s (square 4 "solid" "blue"))
> s
.
> (length (image->color-list s))
16
> (image->color-list s)
(list
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255)
(make-color 0 0 255 255))
It seems that each color is being counted four times. Is this because the image is considered to be three dimensional?? I'll have to check with the professor-or perhaps anyone reading this may have some advice??
My next question comes from Part b, where it refers to pixels, color-list and bitmap. I pulled up the corresponding Lecture worksheet from week 7 which had some helpful explanations. I understand that color-list pulls a list of colors, in numbers. The pixels function was a bit less clear. So the pixels function operates to chose the color-list on a pixel-to-pixel basis? Would a length 5 square have 25 pixels??
Looking over the past exam, its also apparent that recursions will be very important to study. Have to run to class now, but will update with more practice with recursions from past exams!
No comments:
Post a Comment