Assume that if f calls g and g raises an exception that f


Exceptions and Recursion

Here is an ML function that uses an exception called Odd.

fun f(0) = 1
| f(1) = raise Odd
| f(3) = f(3-2)
| f(n) = (f(n-2) handle Odd => ∼n)

The expression ∼n is ML for -n, the negative of the integer n.

When f(11) is executed, the following steps will be performed:

call f(11) call f(9) call f(7)...

Write the remaining steps that will be executed. Include only the following kinds of steps:

• function call (with argument)
• function return (with return value)
• raise an exception
• pop activation record of function off stack without returning control to the function
• handle an exception

Assume that if f calls g and g raises an exception that f does not handle, then the activation record of f is popped off the stack without returning control to the function f.

Request for Solution File

Ask an Expert for Answer!!
Basic Computer Science: Assume that if f calls g and g raises an exception that f
Reference No:- TGS01269938

Expected delivery within 24 Hours