Reference no: EM13963490
Continuations
In addition to continuations that represent the "normal" continued execution of a program, we can use continuations in place of exceptions. For example, consider the following function f that raises an exception when the argument x is too small:
exception Too Small;
fun f(x) = if x<> then raise Too Small else x/2; (1 + f(y)) handle Too Small => 0;
If we use continuations, then f could be written as afunction with two extra arguments, one for normal exit and the other for "exceptional exit," to be called if the argument is too small:
fun f(x, k normal, k exn) = if x normal(x/2); f(y, (fn z => 1+z), (fn () => 0));
(a) Explain why the ?nal expressions in each program fragment will have the same value for any value of y.
(b) Why would tail call optimization be helpful when we use the second style of programming instead of exceptions?
What are the capacity implications of the marketing campaign
: Suppose that AlwaysRain Irrigation's marketing department will undertake an intense ad campaign for the bronze sprinklers, which are more expensive but also more durable than the plastic ones. What are the capacity implications of the marketing cam..
|
Which of the following statements is necessarily true
: If the temperature of the contents is increased by 10 C degrees, the reading on the Kelvin thermometer should increase by 273 K
|
What is covalent bonding
: What is covalent bonding? why is it different from ionic bonds?
|
Calculate the first order energy shifts for the ground
: Consider a particle in the one dimensional infinite square well potential with width L. The perturbation potential W(x) = b sin(xpi/L) is added to the bottom of the infinite well. Calculate the first order energy shifts for the ground and first e..
|
Continuations in place of exceptions
: In addition to continuations that represent the "normal" continued execution of a program, we can use continuations in place of exceptions. For example, consider the following function f that raises an exception when the argument x is too small:
|
Control flow and memory management
: An exception aborts part of a computation and transfers control to a handler that was established at some earlier point in the computation.
|
The reaction involved in the purification of nickel
: The reaction involved in the purification of nickel is given below. Ni(s) + x CO(g) → Ni(CO)x(g)
|
Discuss the innovation involved in product development
: Choose a product that they are interested in or provides the required information to discuss the innovation involved in its development - What aspect of the technology influenced the development and the products
|
Ealuation order and exceptions
: Suppose we add an exception mechanism similar to the one used in ML to pure Lisp. Pure Lisp has the property that if every evaluation order for expression e terminates, then e has the same value under every evaluation order. Does pure Lisp with ex..
|