Question: OZ Programming Language % Q2 Laziness and monolithic functions. % Consider the following two definitions of lazy list reversal: fun lazy {Reverse1 S} fun {Rev

OZ Programming Language

% Q2 Laziness and monolithic functions. % Consider the following two definitions of lazy list reversal:

fun lazy {Reverse1 S} fun {Rev S R} case S of nil then R [] X|S2 then {Rev S2 X|R} end end in {Rev S nil} end

fun lazy {Reverse2 S} fun lazy {Rev S R} case S of nil then R [] X|S2 then {Rev S2 X|R} end end in {Rev S nil} end

% What is the difference in behavior between {Reverse1 [a b c]} and {Reverse2 [a b c]}?

% Do the two definitions calculate the same result? Do they have the same lazy behavior? Explain your answer in each case.

% Finally, compare the execution efficiency of the two definitions. Which definition would you use in a lazy program? % (Generate a very long list e.g. size 10000 and run both reverse fucntions on the two lists, timing with your phone)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!