I haven’t been blogging for a while as it’s exam period. It’s also been busy busy at 24seven. The new product which name you will never guess right.
Today’s paper is on programming, it’s (so-call) advanced concepts. Honestly the whole course’s been a mess but never mind that. I did 3 questions on Java, 2 question on SML and 1 question on Prolog. The Java questions are quite easy. Most of what I studied came out. I planned to do 3 questions out of the 5 Java questions and it went well.
What caught me in a surprise is Prolog which is quite hard, especially the last question which was basically some professor wanting to read some opinion. If I were a computing journalist, I probably choose that question.
SML isn’t that hard. What I studied came out, what I didn’t study I chose not to do. And I quickly went home and I try to see if the average function I wrote work in SML. And it did:
[code lang=“ocaml”]fun average x =
fun sum  = 0.0
| sum (h::t) = h + sum t;
fun count  = 0.0
| count (h::t) = 1.0 + count t;
sum x / count x
I wrote this function very neatly on the paper. I never had so much sense of achievement writing an SML function.
An alternate way of writing would be probably:
[code lang=“ocaml”]fun average x = foldl op+ 0.0 x / real (length x);[/code]
You gotta love foldl sometimes.
Tomorrow’s paper is database. I probably won’t do too well for that. Lots of memorizing to do and my memory’s failing me.