Counting calls under two reduction orders

A function slow(n) takes 30 ms and returns 2 * n; every other operation takes negligible time. Two more functions are defined:


Plain text
cube(x)       = x * x * x
pick(c, a, b) = if c then a else b


Consider the expression


Plain text
E = cube(slow(2)) + pick(false, slow(1), slow(5))


Under applicative order, every argument is evaluated to a value before a function body runs. Under normal order, each argument expression is substituted unevaluated into the body and evaluated each time the body uses it. In both strategies *, + and the condition of if are strict.


Give, as whole numbers, the number of calls to slow and the total time in ms under applicative order, the same two quantities under normal order, and the value of E.

Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Evaluation Strategies Questions: