Problem regarding the exceptions and recursion

Assignment Help Basic Computer Science
Reference no: EM13963480

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.

Reference no: EM13963480

Questions Cloud

Implications of false beliefs about homosexuality : Reflect on the following statement made by Stanton L. Jones in the assigned article, "Sexual Orientation and Reason: On the Implications of False Beliefs About Homosexuality"
Tail recursion and exception handling : Can we use tail recursion elimination to optimize the following program?
What is the mass of the ice cubes dropped : Two ice cubes at 0.0 oC are dropped in an insulated container containing 93.8 g of water at 27.0°C. After all the ice is melted, the final temperature of the system is 17.0 °C. What is the mass of the ice cubes dropped? Assume that the container has ..
What is the momentum amplitude for this wavefunction : What is the probability of finding the particle in the interval 0 less than or equal to x less than or equal to pi/2b? What is the momentum amplitude for this wavefunction?
Problem regarding the exceptions and recursion : 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.
Trying to figure out ionic bonds and figuring out formula : Trying to figure out ionic bonds and figuring out formulas.  For example...K+1 and CO3-2 combines to form what.
How many different microstates are available to this system : Consider a system of two Einstein solids, A and B, each containing 10 oscillators, sharing a total of 20 units of energy. Assume that the solids are weakly coupled, and that the total energy is fixed.
Handling the exception tl : Consider the function fun g(l) = hd(l) : : tl(l) handle Hd => nil; that behaves like the identity function on lists. The result of evaluating g(nil) is nil. Explain why. What makes the function g return properly without handling the exception Tl?
What is the primary potential problem with ethical egoism : In your opinion, what is the primary potential problem with Ethical Egoism as a moral theory? Explain

Reviews

Write a Review

Basic Computer Science Questions & Answers

  What type of system was selected for network administrator

What type of system was selected for your computer administrator. What type of system was selected for your network administrator. What type of system was selected for yourself, as business manager

  Describe significance of having test coupled with real users

Describe the significance of having test coupled with real users' views of product at the end of development effort,even if it is test of a prototype and not the completely developed software.

  Horizon books is a bookstore in downtown madina munawara

Horizon Books is a bookstore in downtown Madina Munawara. It carries an inventory of approximately 50,000 books. Customers come in and browse the shelves, select their books, and take them to one of three cashiers positioned in different parts of the..

  Analyze the recent

U.S. > Analyze the recent (since Summer '14) decrease in the price of oil. How has supply and demand affected the price of oil today? Looking at the demand and supply determinants, what will most likely happen to the price by mid this year?

  Create the new instance of problem with graph

Assume we replace each edge cost Ce by its square, Ce^2, thereby creating the new instance of problem with same graph but different costs.

  What is the danger of not having a strategic intent

What is the danger of not having a strategic intent? In your answer, assume you are a hospital in a city with a population of 30,000 people, located about 50 miles away from a large city.

  Show how mips can implement the instruction swap

Show how MIPS can implement the instruction swap $rs $rt, which swaps the contents of registers $rs and $rt. Consider the case in which there is an available register.

  Add delete and update records within a table

Add, delete, and update records within a table.  Write questions that select specific records from a table for viewing. View data on a PDA.

  Names and numbers of london-based suppliers

Give the relational algebra expression for the following English queries. 1. Get the supplier# who supply all the blue parts

  Calculate the equation of this best fit straight line

Linear regression is a method for calculating the equation of the "best" straight line that passes through a set of points. By "best," we mean the "best fit" straight line—the one that passes as closely as possible to as many points as possible. To c..

  Word-processing drawing tools

For drawings, you may use your word-processing drawing tools, graphic applications, or scanned hand drawings and insert them in the main document.  Create a zip file containing your document and source code files.  Show all of your work.

  Performing swot analysis on viability of upgrading server

Carry out a SWOT analysis on the viability of upgrading to Server 2008.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd