

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


fun thrice f x = f(f(f(x)));
Use the Hindley-Milner type-checking algorithm (or any logical procedure) to deduce the type of thrice(). You are required to determine the most general type.
(i) Explain the difference(s) between the if-expression and if-statement in C. (ii) Given the semantics of the assignment statement in C, will the following fragment of code work? Can it be made to work? Justify your answer. (a > b)? (a=3): (b=4);
int i; int b[5];
void q (int x) { i++; x++; }
main() { i=1; b[1]=3; b[2]=4; q(b[i]); printf(โโ%d \nโโ,b[i]); }
What value will be printed assuming that C uses the following parameter passing mechanisms: (i) Pass by value, (ii) Pass by value-result, (iii) Pass by name.
(i) Describe how you would declare a type for Binary Search Trees on integers in ML. (ii) Write a function named PRE-TRAVERSE(), which takes as input a Binary Search Tree of the form described above and outputs the list of elements obtained by a pre-order traversal of this tree.