Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help 3. The list iterator of WHILE++, as introduced above, could also be regarded as a mere syntactic extension of WHILE (i.e. syntax sugar).

Need help

image text in transcribed

image text in transcribed

3. The list iterator of WHILE++, as introduced above, could also be regarded as a mere syntactic extension of WHILE (i.e. syntax sugar). To demonstrate this, explain in detail how the command foreach x in E {S} can be translated into WHILE (without list iterators obviously) maintaining its original behaviour (i.e. semantics). Consider all possible forms of appear- ances of the iterator. Explain any assumptions you make. [18 marks] 4. According to the above, can we decide more problems with WHILE++ pro- grams than we can decide with WHILE-programs? Explain your answer briefly. [10 marks) 5. Translate the program prog in Figure 1 into program-as-data notation so that you can use it to test the answer for the next question. Submit this as a text file named progasdata.txt. This file must only contain text (no Word documents here!) representing the program as WHILE++ data. Make sure you follow the specification of WHILE++ programs-as-data format as given further above. [16 marks) prog read L foreach x in L { while XL Y:= cons nil Y; X:= tl x } } } write Y Figure 1: WHILE++-program prog 3. The list iterator of WHILE++, as introduced above, could also be regarded as a mere syntactic extension of WHILE (i.e. syntax sugar). To demonstrate this, explain in detail how the command foreach x in E {S} can be translated into WHILE (without list iterators obviously) maintaining its original behaviour (i.e. semantics). Consider all possible forms of appear- ances of the iterator. Explain any assumptions you make. [18 marks] 4. According to the above, can we decide more problems with WHILE++ pro- grams than we can decide with WHILE-programs? Explain your answer briefly. [10 marks) 5. Translate the program prog in Figure 1 into program-as-data notation so that you can use it to test the answer for the next question. Submit this as a text file named progasdata.txt. This file must only contain text (no Word documents here!) representing the program as WHILE++ data. Make sure you follow the specification of WHILE++ programs-as-data format as given further above. [16 marks) prog read L foreach x in L { while XL Y:= cons nil Y; X:= tl x } } } write Y Figure 1: WHILE++-program prog

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Question What integration level should an employer choose?

Answered: 1 week ago