Reading the structure of a continuation

A programmer is reviewing short Python fragments involving an integer x and a supplied continuation k. Match each fragment to its role. Treat each return fragment as the complete body of a function.

Match each term
A.

Creates a function that returns its received value unchanged.

B.

Waits for the receiver to finish and then performs an additional calculation.

C.

Creates a function that adds nine to a future received value and forwards the result.

D.

Immediately delivers an adjusted value, leaving no work after the receiver finishes.

return k(x) + 9

lambda v: v

lambda v: k(v + 9)

return k(x + 9)

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 Continuation Passing Style Questions: