Answer to Question s22

Type error. Expression 'new List' has type List*. A value of type List* cannot be stored in a variable of type List.

Notation. Use cons in C++ functions, not :. The right-hand operand of : is required to be a list. Expression head(L) + 1 has type int.

Incorrect. L does not change in the loop. So if L is initially empty, the loop never stops. The value of expression s:(head(L)+1) is being ignored, so the loop body is a statement without any effect.