[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Is there a function for auto currying in Elisp?
From: |
Clément Pit-Claudel |
Subject: |
Re: Is there a function for auto currying in Elisp? |
Date: |
Thu, 21 Dec 2017 11:50:16 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 |
On 2017-12-21 11:13, Nicolas Petton wrote:
> Philipp Stephani <address@hidden> 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")
apply-partially is the closest you'll get, I think.