4.7 Curried Closure
Closures may receive zero or more parameters. Each time we call a closure, we’re expected to pass arguments for each of these parameters. However, this can get tedious if one or more arguments are the same between multiple calls to a closure. We can ease this pain by prebinding some closure parameters.
Closures with prebound parameters are called curried closures—despite the name, it has nothing to do with my favorite Indian dish. (The term curry
comes from the name Haskell B. Curry, famed mathematician who contributed to lambda calculus, and was coined by Christopher Strachey, Moses Schönfinkel, and Friedrich Ludwig.
Gottlob Frege invented the concept.)
When we
curry a closure, we’re asking the parameters to be prebound. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access