HomeChallengesRepsProblemsLeaderboardTake a challenge

Decide, then do

To test whether a refund is owed you currently need a mailer and a ledger.

Intermediate18 min on the clock4 graded checks · 100 pointsFunctions as Values
Graded by running your code against real cases.

What you build

  • Write decideRefund(order, now) returning a plain decision
  • Let it touch nothing but its two arguments
  • Take the clock in as an argument rather than reading it
  • Write applyRefund(decision, io) that carries the decision out
  • Keep every effect in applyRefund and none in decideRefund

Done means

The decision is pure and testable alone; the effects happen only in the shell.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else. Each one runs your code; it is not a search for keywords.

  1. The decision needs nothing but its arguments+30Decide, then do
  2. It gets the rule right, including the boundary+25Decide, then do
  3. The shell carries out an approved decision+25Decide, then do
  4. A refused decision causes no effects+20Decide, then do

What it teaches

The rest of Functions as Values