# #21: Defining Curried Functions

Tagged as challenge

Written on 2018-01-30

### Part 1

Write define-curried which defines a curried function. That is,

(define-curried-function (clog b x)
(/ (log x) (log b)))

will define clog so that it's equivalent to:

(lambda (b)
(lambda (x)
(/ (log x) (log b))))


### Part 2

Note: This is difficult or impossible to write in full generality in some languages.

Write a combinator called $\mathrm{curry}_n\,f$ which takes a function $f$ of $n\ge 1$ arguments, and produces a fully curried version of $f$. (If you can compute $n$ from $f$, when you may elide $n$ as an argument.) It should satisfy the following equations:

• $\mathrm{curry}_1\,f = f$ for unary $f$, and
• $\mathrm{curry}_n\,f = x_1\mapsto\mathrm{curry}_{n-1}\big( (x_2, \ldots x_n)\mapsto f(x_1,\ldots, x_n)\big)$ for $n$-ary $f$.