Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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?

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91631510

Have any Question?


Related Questions in Computer Engineering

In terms of reducing the total number of memory accesses a

In terms of reducing the total number of memory accesses a program might require. Using the arithmetic expression S = (A+B)-(C+D), support this statement.

Task 1create an array that holds a 20 random integers

Task 1: Create an Array that holds a 20 random integers between 1-50. Create an iterator that will return the memory address and value for each integer present in the Array. Task 2: Update Assignment 1 Task 2. Pass the v ...

Explain why a u s recession that occurs as the rest of the

Explain why a U. S. recession that occurs as the rest of the world is expanding will tend to reduce the U. S. Trade deficit.

We might consider a regression of the number of group

We might consider a regression of the number of group members and the efficiency of project completion. Which of those would be the dependent and which would be the independent variables?

Question 1 describe and explain the role and function of

Question: 1. Describe and explain the role and function of network connectivity in current computing. 2. Describe and explain the protocols and interactions that implement network communications. 3. Describe and explain ...

Give an example of a binary relation which is not

Give an example of a binary relation which is not transitive, and then give an example of a binary relation which is reflexive and transitive but not connected.

Submit a 2- to 3-page paper in which youidentify an

Submit a 2- to 3-page paper in which you: Identify an intercultural area Intercultural interaction with a person from a culture different from your own. Explain why you have selected this area. Describe your personal cul ...

Describe an ethical conundrum found in a magazine or

Describe an ethical conundrum found in a magazine or newspaper article, and please give your own thoughts. Give good citations, of course.

Students will create an application that allows the user to

Students will create an application that allows the user to create entities with a dialog window that will be displayed by a ListView in a separate dialog. The main dialog will keep track of how many windows and entities ...

There has been a substantial interest in predictability of

There has been a substantial interest in predictability of stock return in recent years. For example, DeBondt and Thaler (1985, 1987) report that long-term past losers (three- to five-years) outperform long-term past win ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As