- [Pts 2]
Consider the definition
fun f [] = 0
| f (x::L) = (f L) - x;
What is the result of f [0,1,2]; ? (only one answer, please)
- error
- 0
- 1
- ~3 (remember that "~" in ML is the unary minus sign)
- [Pts 2]
What is the effect of the following sequence of declarations? (only one answer, please)
val (x,y) = (3,true);
val x = 2;
- The truth value false, because 2 is not equal to 1
- Error, because the keyword "val" expects a variable afterwards
- Error, because true and 3 have different types
- x is associated to the value 2 and y is associated to the value true
- [Pts 2]
What is the result of the expression tl [0,1,2,3]; (only one answer, please. Remember that tl represents the function "tail of a list".)
- [3]
- [1,2,3]
- error
- the pointer to the last element of the list (i.e. to the element which contains 3)
- [Pts 4]
Consider the following definition:
fun app [] L = L
| app (x::K) L = x::(app K L);
For each of the following expressions, say what is the result, or say whether it's an error.
- app [] []; []
- app [1,2] [3]; [1,2,3]
- app [[1],[2]] [[3]]; [[1],[2],[3]]
- app [[1],[2]] [3]; error