all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Nicolas Petton <nicolas@petton.fr>
To: Philipp Stephani <p.stephani2@gmail.com>
Cc: Emacs Devel <emacs-devel@gnu.org>
Subject: Re: Is there a function for auto currying in Elisp?
Date: Thu, 21 Dec 2017 17:13:09 +0100	[thread overview]
Message-ID: <87r2rohxey.fsf@petton.fr> (raw)
In-Reply-To: <CAArVCkRFhmZw_yRWsx=EM-n=q5BZbEexTY4jzokzFvrMWb9G8Q@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 713 bytes --]

Philipp Stephani <p.stephani2@gmail.com> writes:

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

I'm looking for function that would curry arguments, as opposed to a
partial application.

For instance, it would transform a function that takes A B and C as
parameters into a closure like:

  (lambda (a)
    (lambda (b)
      (lambda (c)
        (funcall f a b c))))

(Meaningless) example:

  (let ((people '(((name . "Bob") (age . 21))
                  ((name . "John") (age . 32))))
        (get (curry #'alist-get)))
    ;; Retrieve all names
    (mapcar (funcall get 'name) people)) ;; => ("Bob" "John")


Nico

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

  reply	other threads:[~2017-12-21 16:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-21 14:41 Is there a function for auto currying in Elisp? Nicolas Petton
2017-12-21 15:36 ` Philipp Stephani
2017-12-21 16:13   ` Nicolas Petton [this message]
2017-12-21 16:50     ` Clément Pit-Claudel
2017-12-21 16:56       ` Nicolas Petton
2017-12-21 17:22         ` Clément Pit-Claudel
2017-12-21 18:00           ` Nicolas Petton
2017-12-21 16:48 ` vlnx
2017-12-21 21:04   ` John Wiegley
2017-12-21 19:13 ` Stefan Monnier
2017-12-22  9:14   ` Nicolas Petton
2017-12-22 13:51     ` Stefan Monnier
2017-12-22 15:34       ` Nicolas Petton
2017-12-26 18:56         ` John Wiegley
2017-12-22 15:38       ` Nicolas Petton

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r2rohxey.fsf@petton.fr \
    --to=nicolas@petton.fr \
    --cc=emacs-devel@gnu.org \
    --cc=p.stephani2@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.