- [Pts 2]
Consider the definition
fun f [] = 0
| f (x::L) = x - (f L);
What is the result of f [0,1,2]; ? (only one answer, please)
- error
- 0
- 1
- ~1 (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 = 1;
val (x,y) = (2,true);
- The truth value false, because 2 is not equal to 1
- Error, because the keyword "val" expects a variable afterwards
- Error, because true and 2 have different types
- x gets associated to the value 2 and y gets associated to the value true
- [Pts 2]
What is the result of the expression hd [0,1,2,3]; (only one answer, please. Remember that hd represents the function "head of a list".)
- 0
- [0]
- error
- the pointer to the first element of the list (i.e. to the element which contains 0)
- [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 [0] []; [0]
- app [0] [1,2]; [0,1,2]
- app [0] [[1,2]]; error
- app [[0]] [[1,2]]; [[0],[1,2]]