mrry (Happy New Year)
Blog Computing Science 2S - Functional Programming 2 3/Jun/2003

I was counting on this to be an easy one. There was too much going on around it (compare the last two articles, and the ones on this Thursday and Friday) to dedicate much time to it.

But why, oh why didn't I memorise the exact definition of foldr?

Overall, this wasn't the shocker that was IM2, but it had enough to rile me on the bus home.

The marking inequalities arose again here: 15 marks for two function definitions and a proof by structural induction (on a Binary Tree <gasp>); versus 15 marks for the definition of foldr. (With foldr, I forgot that the type was (a -> b -> b) -> b -> [a] -> [b], instead believing that it was all a's. However, I can't complain about this - I messed up the generous question, but c'est la vie.

You'll maybe be wondering what my bugbear is. The very last question, of course!

6. Define a Haskell algebraic type to represent course modules. Each module has the following attributes: the module name, the number of students taking the module, and a list of matric numbers of the students who have passed the module.

(c) Define a function passrate which, for given modules x and y, returns the proportion of students who have passed either module x or module y.

Besides the fact that we haven't worked with Floats/Doubles/Rationals, so proportion calculation was a bit of a surprise, consider what the question is asking.

The function is given two modules, each with a possibly-different number of students taking it. Say, for example, that m people take module x, and n take module y. How many people take both exams? We know that it is at least min{m,n}, and at most (m+n), but not the exact number; nor is it calculable from the information that we are given about the modules.

We can calculate the number of students who passed either exam, certainly (it was in the previous part of the question); but to find the proportion, by what number should we divide? I propose that this question was insoluble.

Ah well, nothing like an FP2 exam to put the colour back in your cheeks....




Gary said:
You are quite right. I was thinking about it just after I posted that last comment and I can see no way of getting the number of students.

If you email Muffy (which I think you should), let me know (via email if possible) what she says?

Fiona Cassidy said:
I thought AF2 wasn't as bad as I thought it was going to be, a pleasant surprise, but FP2 was a complete nightmare for me. I still had logical equivalences running through my head I couldn't concentrate. The exams were too close together yesterday and it didn't help I had 2 exams the day before too.
Thank goodness for resits.

Derek said:
Touché! Even after the event it haunts me....

The lists of students were only the ones who passed though - so we can have no idea of the total number of students who actually took the modules, so we can't find the proportion of a number that (I still believe) we can't calculate.

Maybe I'll e-mail Muffy.



Gary said:
I don't think we could have had a more different experience today.

I thought AF was a nightmare: I'm terrible at induction, so you can probably see where I went wrong.

FP was a great though. foldr was one of the functions I memorised, so was the easiest 15 marks in human history (incidently, it's (a -> b -> b) -> b -> [a] -> b, not [b] at the end).

For the last question, there are unique identifiers for each student via the matric numbers. List them all (no duplicates) and then get the Length of the list (although that's not what I did in the exam).





Please enter the number 2198 in the box below:

CommentsTell a friend about this page

Your Name

Your E-Mail

Your friend's E-Mail


< # Scottish Blogs ? >
Technorati Profile
Listed on BlogShares

Subscribe to the mrry RSS feed
More about RSS.
Trackback URL for this article: