Thursday 10 December 2015

More and more and more review

I'm continuing to go over the Final Exam from the last spring session. Question 2 isn't working for me when I tried to complete it in Racket.


Am I missing something??

> (define-struct status (a d))
> (define T (triangle 10 "outline" "black"))
                                              
> (define TT (triangle 10 "solid" "black"))
> (define (draw s) (rotate (* 120 (status-a s)) (above T (beside T TT))))
> (draw (make-status (0 1)))
function call: expected a function after the open parenthesis, but found a number
> (make-status (0 1))
function call: expected a function after the open parenthesis, but found a number
It seems like Dr. Racket is asking for a function for d. I also had this question while trying to answer it by hand, so I thought Racket could help. I'll bring it to office hours on Monday.

I'm also finding this question tricky!! But I'm on the right track so far.

 
 
> (define (c n) (circle n "outline" "black"))
> (c 10)
.
> (repeated (c (range 10 55 10)) 5)
circle: expects a non negative real number as first argument, given (list 10 20 30 40 50)
> (define circles (map c (range 10 55 10)))
> (define circles2 c (map c (range 10 55 10)))
define: expected only one expression after the variable name circles2, but found 1 extra part
> (circles (map 10))
map: arity mismatch;
 the expected number of arguments does not match the given number
  given: 1
  arguments...:
   10
> (circles (map 10 (range 10 55 10)))
map: expects a procedure as 1st argument, given 10
> (circles (map c (range 10 55 10)))
function call: expected a function after the open parenthesis, but received (list #<image> #<image> #<image> #<image> #<image>)
 
I was able to define c fairly easily. And I think I could write the function for the list of repeated circles, but using range is turning out to be tricky. I tried a few ways using repeated, but defining the transformation using range was unsuccessful. Until I got this! I think I was overthinking the whole thing, much simpler than I had originally assumed.
 
 > (define circles n
    (repeated (c 10) (+ n 10) 5))
define: expected only one expression after the variable name circles, but found 1 extra part
> (define (circles n)
    (repeated (c 10) (+ n 10) 5))
circles: this name was defined previously and cannot be re-defined
> (define (circles3 n)
    (repeated (c 10) (+ n 10) 5))
> (circles3 10)
function call: expected a function after the open parenthesis, but received 20
> (map c (range 10 55 5))
                    
(list . . . . . . . . .)
> (map c (range 10 55 10))
(list . . . . .)
I'll keep working, check in with any more issues...

Wednesday 9 December 2015

Exam Review Questions

Now that the project is handed in I can focus on preparing for the exam. It's going to be worth 40% of the final grade so it's really important that I do well! Up until this point in the course I feel pretty comfortable with the material and did well on Test 1. Test 2 isn't up on Markus yet so I'm not sure about that one, but otherwise both projects went fine and most weekly quizzes I've scored 5.5+. I'd be happy with a B+, especially considering my lack of computer knowledge prior to this course.

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!


Success!!

Ha! Finally finished the project. It ended up not being nearly as terrible as I thought. As I suspected working with poems over images was much more manageable. That's not to say I didn't have my own issues...

First of all, loading the seven documents into a single folder ended up being a trial in itself. I was able to upload the documents to my computer fine, but when I attempted to open them in the Racket program they were nowhere to be found. Perhaps Racket couldn't read them properly? I again downloaded the files but them tried to open them in the program. Still unable to save them in Dr. Racket together. A friendly t.a. in the computer science help center fixed that in one minute.

I opened up the dictionary and took a peak. I'm also studying linguistics at the moment so it was interesting to peak at the vowel translations and try and figure out the pattern it was using.

ABSTENTION  AH0 B S T EH1 N CH AH0 N
FINGERTIPS  F IH1 NG G ER0 T IH2 P S
PHEDRA  F EH1 D R AH0

So the vowels seem to be classified more generally (AH, EH) rather than with each phoneme representing a symbol like in the IPA (International Phonetic Alphabet). The following numbers probably operate as a specifier on the initial vowel encoding. For example, in fingertips, the initial IH has a 1 and the latter, a 2. Perhaps that has to do with the vowel features, where the first IH is nasalized due to its relation to the following NG? While the second IH is a more regular sounding /I/ and then encoded with a 2. What then would a 0 mean? In abstention, AH is used for both a /AE/sound and also later, a /U/ sound...doesn't seem consistent.

Moving on, there was some debate within my group regarding the first function, lookup-entry. This functions contract was to decide if a given word was in the dictionary, then extract it and the other information on that line. My first assumption was to use the function member? to implement this, but this would then give us a Boolean...which is not that helpful. I fooled around with member? until my partner had a better idea, which I don't think I'm supposed to write about here.

Next, I also spent a lot of time on the vowel? function. I initially wanted to define this function by coding it to look for any entries with 2-3 units. But looking at the dictionary data I saw that several consonants were similarly encoded with 2 units (CH, NG) so that wouldn't work. Luckily my group had a way to circumvent this problem by analyzing phoneme entries based on another feature.

Overall this project was a lot less painful than the first one. Now its time to start studying for the final! Will update soon with more questions, maybe even a nice study plan

Thursday 3 December 2015

The Post-Project Post

The due date of PP1 played out like this: wake up in a procrastination hangover. Speed over to Robarts to plow through the assignment. Realize I am completely lost and need help. Wander the Bahen center in hopes of meeting a friendly helper. Find such person! Feel increasing inadequate as a first-year Computer Science student tries to explain random-adjacent. Huddle outside office hours with other confused students in PP Purgatory. Admit defeat and turn the damn thing in...

So the whole thing turned out to be an ordeal. I'm a 3rd year student and can say that in my past UofT experience, I rarely struggle this helplessly with the material (given reasonable effort). I've been doing well on weekly tests and got an A- on the midterm (haven't seen Test 2) so I thought that the PP1 would come relatively easily. In isolation, I understand the functions including their purpose and implementation, but it seems like integrating the course work and the interactions between functions is tricky.

I've just begun sorting through PP2. At first glance it actually seems much more accessible than the previous assignment. The fact that I am able to view the content being manipulated (the poems) means that I can see exactly how the function is working/not working. The first PP was less tangible in this way. Similarly the concepts regarding what the functions purpose is, is much clearer. In the first PP, I needed to mentally represent the maze space and then imagine how the function would operate. Working with words is much easier for me than working with numbers! Hence why I am a Psychology/Cog Sci major...

I'll definitely be getting a head start this time around, I think I've learned my lesson this semester. Will return with updates

Friday 13 November 2015

So that Programming Project..

Where to begin...

I've just taken my first serious look at the Programming Project and immediately have an overwhelming list of questions. Is there some sort of graph or plane I should be superimposing the maze to? What exactly is a cell? I understand that it contains a number for x and a number for y, so would this just be a point? Should everyone's maze turn about to look the same or are there several ways to complete this task?

I feel confident in my ability to utilize many of the functions we've been practicing in lecture like map, apply, structs, list manipulations etc. but am unprepared to design something as complex as the maze. So far, there hasn't been much top-down design that students have employed. I'm further concerned that I was told to begin the PP before the test next week as it will be a useful study tool. I've read over the project details a couple times now and don't have a clue where to start. I will be a regular fixture at the computer science help center this week!

In better news, American thanksgiving is coming up and I will be spending a short vacation weekend with family. After unsuccessful attempts at the project, I made a Turducken!!


Friday 6 November 2015

First Impressions and a Fickle Dr. Racket

Entering this school year, I knew I could no longer procrastinate taking this computer science course I had been dreading. Admittedly I was completely ignorant to what it would entail, or anything really, having to do with technology. I cherish my Nokia flip phone and am a terrible driver. On the first day of lecture I imagined a room full of students breezily writing code as I fumbled to change my view settings, praying the professor wouldn't notice. Instead the first few classes were more about manipulating pictures of Koalas and explaining Dr. Racket. Although I'm embarrassed to say how many attempts it took me to correctly enter (require picturing-programs) in the first tutorial.

The layout of the course seems to be geared to novice Computer Science students like myself. I like that we've progressed at a step-by-step basis, building and integrating new functions. Overall the course work hasn't been overwhelming or out of reach. Nested circles, the apply function all appear to be complicated but when broken down, are actually a set of more simple operations utilized in tandem. This has been one of the major points I've pulled from this class so far! That the image and number manipulations which look so complex at first can be analyzed into their smaller components. This has made the idea of computing much more comfortable and approachable for me.

However the exactness of form in designing functions has definitely been an issue. I find that I am not always sure what requires brackets, spaces, dashes or whatever else. Since Racket is so sensitive to this, I am usually left reading and cursing and rereading my functions before I have any success. I'm also interested to find out how all of our learned functions will relate to our ability to complete more sophisticated images and manipulations. Perhaps the Programming Project will be related to this?

We should be getting more info on the PP today in lecture, so I'll probably be here to vent about that in the near future..