(Solved) : Exercise Carrying Lazy Evaluation Noticing Pros Cons First Need Agree Code Mysum 0 Mysum X Q44135409 . . .
This exercise is about carrying out lazy evaluation and noticingits pros and
cons.
First we need to agree on some code:
mysum [] = 0
mysum (x:xt) = x + mysum xt
myor [] = False
myor (x:xt) = x || myor xt
“||” is implemented as:
False || c = c
True || _ = True
Exercise 1 [3 marks]
———-
Show the lazy evaluation steps of
mysum (1 : 2 : 3 : [])
until you obtain a single number. It is best to add clarifyingparentheses: If
you have “foo + bar + quux” it is best to write either “(foo + bar)+ quux” or
“foo + (bar + quux)” to indicate which one you mean.
Exercise 2 [3 marks]
———-
Show the lazy evaluation steps of
myor (True : False : True : [])
until you obtain a single boolean.
Expert Answer
Answer to This exercise is about carrying out lazy evaluation and noticing its pros and cons. First we need to agree on some code:…
OR