Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

SUMMARY OF ASSIGNMENT.

In this assignment you will make some modifications to the interpreter for L3. The interpreter has already been modified slightly for convenience. In particular, the annoying need for "dummy" variables to assign to, in order to return a value from a procedure, has been removed. Many of the commands have a "block" as a component, and where a block used to have a list of commands, it now allows both commands and expressions. This cleans up a bunch of examples.L3 has been updated with syntax for some new commands and expressions:

"for" loops, mutable pairs, and a "fluid let" construct. These will be further explained in the questions. Your job is to write evaluator clauses for these additions.

You should start by carefully reading *all* the supplied code *except* for the parser. The new L3 data type clauses have been indicated with a comment, but a few other parts have been changed a bit for your convenience in doing this assignment.

There are 3 equally-weighted questions. Each question describes the L3 addition you need to update the evaluator for. To make sure you've done everything, check that there are no more occurrences of "undefined" in this file. Test data can be found at the end of this file.

QUESTION 1. Standard "for" loops. Example:

r=1 n=5:
for i=1,n by 1 do r := *(i,r) end;
print(r)

computes n factorial for n=5. The "by" part say how much to increment i by each time through the loop. The "by" can be omitted if it's 1 as in this example. Note: i can be assigned to in the body of the loop, but any such value should be ignored at the start of each iteration.

QUESTION 2. "Fluid let." This is a command of the form

flet x = e

in b

where e is an expression and b is a block (bindings + commands). It is very different from the familiar "let". The variable x must *already* have a binding. The body b of the flet is evaluated in the same environment as the flet itself, i.e. a new reference is *not* created for x. Right at the start of evaluation of b, x's reference is updated to be the value of e. Right after the evaluation of b, x's reference is restored to the value it had at the start.

QUESTION 3. Mutable pairs (as in Lisp/Scheme). These are pairs that can have their components destructively modified. Pairs are created using "(,)", accessed using fst and snd, and destructively modified using setfst and setsnd. Example:

t = ( (0,1), (2,3) ):
print(t);
setfst(snd(t), 4);
print(t)

prints

((0, 1), (2, 3))
((0, 1), (4, 3))

The update for pairs to the type EVal indicates how such pairs should be implemented. Note that you will also need to update applyPrimitive for fst and snd. There is also a "null" constant added to L3 so that pairs can be used to represent lists (null is like nil or []).

Attachment:- assignment.rar

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M91521572
  • Price:- $60

Priced at Now at $60, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Question suppose message a is one block long suppose that

Question : Suppose message (a) is one block long. Suppose that an attacker has received the MAC (t) for a using CBC-MAC under some random key unknown to the attacker. Explain how to forge the MAC for a two-block message ...

Legacy industries inc has a historic pe multiple of 15 a

Legacy Industries Inc. has a historic P/E multiple of 15, a current EPS of $2.50 projected to grow by 4% in the coming year, and a forward looking P/E multiple of 18. With this information please estimate the current pri ...

You are saving up to buy a toyota tundra which costs 35000

You are saving up to buy a Toyota Tundra, which costs $35000 now. You don't think the price of the Toyota will change over the next two years. You don't want to borrow to pay any of this cost. You now have $10000 toward ...

Video and disruption report assignmentoverviewfor this

Video and Disruption Report Assignment Overview For this assessment task, you will create a two-minute video and written proposal about the impact of a particular technology on an industry or field. The purpose of this a ...

1 select one of the topics listed below and discuss

1. Select one of the topics listed below and discuss it. Describe an application that you have to solve by using at least 2 Excel functions. It can be Math, Statistics, Engineering, Financial, etc. Explain what Excel fun ...

Determine the critical values for a left-tailed test of a

Determine the critical? value(s) for a? left-tailed test of a population mean at the alpha α=0.01 level of significance based on a sample size of n=15.

Is smartart graphic and table slide important for

Is Smartart graphic and Table slide important for PowerPoint Presentation? How would it benefit?

What is the purpose of load balancing i need full

What is the purpose of load balancing? (I need full explanation) I already know what load balancing is, I just need to know why we use it

Is it okay too copy a fellow classmate programming code

Is it okay too copy a fellow classmate programming code when you are stuck? Will that break a school honesty policy? Please explain

Why should one listen to peter drucker in other words what

Why should one listen to Peter Drucker? In other words, what are his credentials/expertises? Provide at least three reasons. Copy question to the beginning of answer.

  • 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