HomeChallengesRepsProblemsLeaderboardTake a challenge

Functions that build functions

once, memoize and retry. Three functions that take a function and return one.

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

What you build

  • once(fn) returns a function that runs fn at most one time
  • Later calls to it return the first result
  • memoize(fn) calls fn once per distinct argument
  • retry(fn, n) keeps trying until fn succeeds
  • retry rethrows if it never succeeds

Done means

All three wrappers behave correctly, counted by how often the wrapped function actually ran.

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. once runs the function a single time+25Functions as values
  2. once returns the first result afterwards+25Functions as values
  3. memoize calls once per distinct argument+25Functions as values
  4. retry keeps trying, then gives up honestly+25Functions as values

What it teaches

The rest of Functions as Values