So I submitted my project a few hours ago without having to panic about it at all today. And that is because I did my fair share of panicking on Tuesday (the day before the lecture). I guess it was sort of overwhelming when I couldn't get past the second question... After struggling on it for a while (without any progress might I add), I moved on. There were definitely other problems that were easier to fix, like the functions and check-expects for image-width/height (I loved those because they made me feel better about myself)
How I went about fixing the problem with the clarify-image definition was to 1) read the contracts carefully, 2) look at the check-expect and see what I can replace in there to may my function. And then I was stuck there. I realized I needed the clarify-color function, but I didn't know how to implement it. My next resort was to 3) ask Professor Heap for help. While I was walking to SF, it suddenly came to me that I needed to use 'map' to use the clarify function on every pixel of the image (it's weird how when you're not thinking about the problem, the solution magically pops up in your head). But I still had the same problem, I didn't know how to implement the functions into my definition. After talking to Prof. Heap, it definitely helped because he hinted at how I would use the function in the definition and he also pointed out that my placeholders were wrong. After he gave me his input, I felt like I understood the definition more. When I got home, I could not believe how easy the definition seems to me now.
Another major problem that I had with the Project was the definition: check-key. At first, I didn't know how to go about it at all. So I decided to put it off, and come back to it later. And that was the charm (I wish this technique would work for everything). I realized that we had a lesson/tutorial that had this function in it when Prof. Heap first introduced big-bang to the class. I went back to the lecture notes, and saw the setup that I needed to structure my function with 'check-key' in this project.
At first my definition looked like this:
(define (check-key c k)
(make-clocktime
(clocktime-hours c)
(clocktime-minutes c)
(clocktime-seconds c)
(cond
[(equal? k "down") STOP]
[(equal? k "up) GO])))
Then when I went for extra help on Friday, Prof. Heap pointed out that there would be error statement if I pressed keys other then up or down. And there was an error statement stating that my check-expects did not work properly. Thinking back to the previous code in the past lecture notes and Prof. Heap's hints, I modified by definition like so:
(define (check-key c k)
(make-clocktime
(clocktime-hours c)
(clocktime-minutes c)
(clocktime-seconds c)
(cond
[(equal? k "down") STOP]
[(else GO])))
And voila, everything worked!
No comments:
Post a Comment