[ First Question ] Number of questions : 4

Some of the questions will not be immediately obvious from the tutorial material alone.

- ML Self Test - Tutorial Three, Recursion with integers
[ Previous Question | Next Question ]

1. Given the following recursive function definition:

fun f(a, 0) = 1 | f(a, n) = a * f(a, n-1);

Select the value of`f(3,4)` - a)
`0 : int` - b)
`81 : int` - c)
`64 : int` - d)
`27 : int` - e)
`12 : int` - ML Self Test - Tutorial Three, Recursion with integers
[ Previous Question | Next Question ]

2. Select the recursive function which defines the sequence 5, 8, 11, 14, 17, 20 ..

- a)
fun s(0) = 5 | s(n) = n + 3;

- b)
fun s(0) = 5 | s(n) = 3*n + 5

- c)
fun s(n) = 3 * n + 5;

- d)
fun s(0) = 5 | s(n) = 3 + s(n-1)

- e) I don't understand the question.
- ML Self Test - Tutorial Three, Recursion with integers
[ Previous Question | Next Question ]

3. Select the recursive function which defines the sequence "and his dog", "1 man and his dog""2 man 1 man and his dog", "3 man 2 man 1 man and his dog",...

- a) How do concatenate a number onto a string?
- b)
fun medow(0) = "and his dog went to mow a medow." | medow(n) = makestring n ^ (if n>1 then " men " else " man ") ^ medow(n-1);

- c)
fun medow(0) = "and his dog" | medow(n) = n ^ " man " ^ medow(n-1);

- d)
fun medow(0) = "and his dog" | medow(n) = makestring n ^ " man " ^ medow(n-1);

- e)
fun medow(0) = " and his dog" | medow(n) = makestring n ^ " man" ^ medow(n-1);

- ML Self Test - Tutorial Three, Recursion with integers
[ Previous Question | Next Question ]

4. Give the type of the following function:

fun g x a b = 2*a + 3*b;

- a)
`'a -> int -> int -> int` - b)
`int -> int -> int` - c)
`('a * int * int) -> int` - d)
`int -> int -> int -> int` - e)
`(('a -> int) -> int)-> int`

fun f(a, 0) = 1 | f(a, n) = a * f(a, n-1);Select the value of

[ Return to Question | Next Question ]

fun f(a, 0) = 1 | f(a, n) = a * f(a, n-1);Select the value of

fun f(a, 0) = 1 | f(a, n) = a * f(a, n-1);Select the value of

fun f(a, 0) = 1 | f(a, n) = a * f(a, n-1);Select the value of

fun f(a, 0) = 1 | f(a, n) = a * f(a, n-1);Select the value of

f(3,1) = 3 * f(3,0) = 3 * 1 = 3

f(3,2) = 3 * f(3,1) = 3 * 3 = 9

f(3,3) = 3 * f(3,2) = 3 * 9 = 25

fun s(0) = 5 | s(n) = n + 3;

fun s(0) = 5 | s(n) = 3*n + 5

fun s(n) = 3 * n + 5;

[ Return to Question | Next Question ]

fun s(0) = 5 | s(n) = 3 + s(n-1)

s(0) = 5 s(1) = 8 s(2) = 11 s(3) = 14 ...

fun medow(0) = "and his dog went to mow a medow." | medow(n) = makestring n ^ (if n>1 then " men " else " man ") ^ medow(n-1);

fun medow(0) = "and his dog" | medow(n) = n ^ " man " ^ medow(n-1);

[ Return to Question | Next Question ]

fun medow(0) = "and his dog" | medow(n) = makestring n ^ " man " ^ medow(n-1);

fun medow(0) = " and his dog" | medow(n) = makestring n ^ " man" ^ medow(n-1);

[ Return to Question | Next Question ]

fun g x a b = 2*a + 3*b;

fun g x a b = 2*a + 3*b;

fun g x a b = 2*a + 3*b;

fun g(x,a,b) = 2*a + 3*b;

fun g x a b = 2*a + 3*b;

fun g x a b = 2*a + 3*b;

ML Self Test - Tutorial Three, Recursion with integers

[ Previous Question | Back home ]

That is all for now.