Monday, 15 September 2014

Empty Sets and Misunderstandings

The first week of class culminated in working on the exercises for the first tutorial. I found the instructions fairly straight-forward, but I imagine I would have had a bit of difficulty if not for the lecture material. For example, I received a bit of clarity about the behaviour of empty sets; the value of a function returning whether all values in an empty set are in another non-empty set will not be false. Similarly, a function returning whether no values of the empty set are in the non-empty set will also not be false.
Something that I was slightly confused about through the week was what the syntax of the set-building functions meant for how the function worked. Using an example function from class:
def q0(S1, S2): ''' (set, set) -> bool Return whether ... ''' return not all({x in S2 for x in S1})
I was misreading the actual code; thinking that the x value was first referring to the values in S2 and then comparing them to the values in S1. My mistake was pointed out over piazza, and I realized that it is actually the other way round. It was a small misunderstanding, but the realization is infinitely helpful in figuring out what the function actually does.

No comments:

Post a Comment