Required operands and unreachable errors

An evaluator uses selective conditionals and strict left-to-right addition. Calling fail() immediately raises an error and stops evaluation. Each case below is evaluated independently:

  • Case A: if true then 12 else fail().
  • Case B: 12 + fail().
  • Case C: if false then fail() else 7.

Complete the table with each returned integer, or the word error if evaluation raises an error. Also enter the exact number of calls to fail() in each case.

CaseOutcomeCalls to fail
A
B
C

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: