Build fluency in the vocabulary of transforming a multi-argument function into a chain of single-argument steps.
0 / 5 completed
1 / 5
At standup, a dev mentions transforming a function that normally takes three arguments into a chain of three separate functions, each one taking a single argument and returning the next function in the chain until all three have been supplied. What is this technique called?
Currying is exactly this: it transforms a function that normally takes several arguments into a chain of functions, each one taking exactly a single argument and returning the next function in the chain, until every original argument has been supplied one at a time and the final result is produced. A hash collision is an unrelated hash-table concept about two keys sharing a bucket. This one-argument-at-a-time chain is exactly what currying means, distinct from simply calling a function with all its arguments at once.
2 / 5
During a design review, the team curries a multi-argument function specifically so a caller can supply the first argument early and receive back a reusable function still waiting on the remaining arguments. Which capability does currying provide here?
Currying here provides building a family of specialized functions from one general function, since supplying just the first argument to a curried function returns back a new, reusable function that's still waiting on the remaining arguments, letting a caller create as many differently-specialized variants as needed without duplicating the original function's logic. Calling the original multi-argument function directly with every argument supplied all at once every time would offer no way to reuse a partially-supplied version across multiple later calls. This one-argument-at-a-time, reusable chaining is exactly what currying unlocks that a plain multi-argument function call does not.
3 / 5
In a code review, a dev notices the same multi-argument function is being called dozens of times throughout a file with its first two arguments always identical, and only the third argument actually varies from call to call. What does this represent?
This is a missed currying opportunity, since currying the function and fixing its first two identical arguments just once would produce a single reusable function that only needs the third, actually-varying argument supplied on each of those dozens of calls, instead of repeating the same first two arguments explicitly every single time. A cache eviction policy is an unrelated concept about discarded cache entries. This repeated-identical-arguments pattern is exactly the kind of duplication a curried, partially-applied function is designed to clean up.
4 / 5
An incident report shows a data-validation module's calls to a multi-argument validator function became inconsistent across a large codebase, because each call site repeated the same first two configuration arguments by hand, and one call site accidentally passed them in a slightly different order than the rest. What practice would prevent this?
Currying the validator function and fixing its first two configuration arguments once, in a single shared place, produces one reusable, partially-applied function that every call site can share, so the actual configuration values only ever need to be written down correctly a single time, which is exactly the fix for the inconsistency described in this incident. Continuing to repeat the same first two arguments by hand at every call site is exactly what allowed one call site to accidentally get their order wrong. This currying-based fix removes the repeated, error-prone duplication at its source rather than just catching the mismatch after the fact.
5 / 5
During a PR review, a teammate asks why the team curries a multi-argument function into single-argument steps instead of just writing a helper function that already takes all the fixed arguments plus the one varying argument together. What is the reasoning?
Currying produces a single, general chain of single-argument functions that can be partially applied at any point, letting a caller fix however many leading arguments it needs and get back a reusable function for the rest, all from one original definition. A bespoke helper function, by contrast, has to be hand-written and separately maintained for each specific combination of fixed arguments a caller happens to need, which duplicates logic and grows harder to keep consistent as more combinations arise. The tradeoff is that currying's chain-of-single-argument-calls style can read less directly than a purpose-built helper, which is exactly why it's most valuable when many different partial combinations are genuinely needed.