emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a function for auto currying in Elisp?


From: Stefan Monnier
Subject: Re: Is there a function for auto currying in Elisp?
Date: Thu, 21 Dec 2017 14:13:01 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

> I've been looking for a function that would automatically curry its
> argument, but couldn't find it.  Maybe I just missed it?

I'm quite familiar with currying, but in the context of Elisp it's
rather tricky to give a good and reliable specification of what it
should do.  E.g. what should (curry #'apply) or (curry #'list) return?

So, I think we can't magically handle all cases.
Of course, we can do the easy cases:

    (defun curry (f n)
      (if (< n 2)
          f
        (lambda (x)
          (curry (apply-partially f x) (- n 1)))))

but ... I'm not sure we want to encourage this.
What's your use case(s)?


        Stefan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]