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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started