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

  Find a simplified expression for function

find a simplified expression for F = A?BC?D + A?B?D + A?CD + ABD + ABC - Assuming that the inputs ABCD = 0101, BCD = 1001, ABCD = 1011 never occur,

  Draw the relation from the following problem

Draw the relation from the following Problem as an arrow diagram : Let A = {0, 1, 2, 3, 4, 5, 6, 7, 8} and B = {1, 2, 3, 4, 5, 6, 7, 8}. Now let R be a binary relation R from A to B such that for all (x, y) ? A x B, (x, y) ? R if and only if y =..

  Good meetings in software development life cycle

Provide three words or phrases that explain why "good meetings" are important during the Software Development Life Cycle?

  How many entries are there in each of the following

The BTV operating system has a 21-bit virtual address, yet on certain embedded devices, it has only a 16-bit physical address. It also has a 2-KB page size. How many entries are there in each of the following?

  Creat an intrest account for amazon

Write a program with subclass InterestAccount and CDAccount. The driver program (Account.java) must perform following transactions.

  Include a description of the media used for storage

imagine one real life example of each: a multi-file volume and a multi-volume file. include a description of the media used for storage and a general description of the data in the file.

  The execution of the preceding two processes

Show all the possible interleaving of the execution of the preceding two processes.

  Dalvik virtual machine

Explain the similarities and differences of the Dalvik virtual machine and the .NET CLR in more detail. Which one is better? Describe your answer.

  Making it eco-friendly

When you hear the term "making IT eco-friendly", explain how this is related to Information Technology and the environment.

  Develop an appropriate conceptual data model

The proprietors of BigM have approached you and asked if you could design a database to help them manage their business. The management has commissioned you (in your capacity as a Database Management System consultant) to analyse, design and devel..

  About power point presentation

Weekly tasks or assignments (Individual or Group Projects) will be due by Monday, and late submissions will be assigned a late penalty in accordance with the late penalty policy found in the syllabus.

  What are two disadvantages of waterfall

A lot of organizations who use waterfall as their standard development methodology are looking to adopt an Agile methodology instead.  What are two disadvantages of waterfall?

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