[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs]
From: |
Adrián Medraño Calvo |
Subject: |
Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs] |
Date: |
Thu, 14 May 2020 09:26:23 +0200 |
> On 13. May 2020, at 23:03, Jonas Bernoulli <address@hidden> wrote:
>
> Stefan Monnier <address@hidden> writes:
>
>>> You said that there is a macro like this already in Emacs?
>>
>> I don't think it's in Emacs, but I remember seeing something like
>> that somewhere.
>
> You were probably thinking of Oleh Krehel's short-lambda package.
>
> https://github.com/abo-abo/short-lambda
There’s also dollar.el, by Göktuğ Kayaalp (CC’d):
https://github.com/cadadr/elisp/blob/devel/dollar.el
I find it very elegant: it’s just a macro.
;;; Commentary:
;; This package provides a macro named $ where in its body symbols in
;; the form $N where N is a positive integer are to stand for
;; positional arguments to the generated lambda.
;; If the car of the body is a vector though, that vector becomes the
;; argument list of the new lambda.
For example:
($ (+ $1 $2))
expands to:
(lambda
($1 $2 &rest $_)
(let
(($*
(cons
(vector $1 $2)
$_)))
(+ $1 $2)))
(funcall ($ + $1 $2) 4 6)
10
Example usage:
(seq-map ($ (* $1 $1)) '(1 2 3))
(1 4 9)
Using named arguments:
(seq-map ($ [n] (* n n)) '(1 2 3))
(1 4 9)
At first glance, I’d do away with &rest $_ and collecting the arguments in the
$* variable, for better performance. The former could be left to the named
arguments mechanism.
Göktuğ Kayaalp, would you be willing to include dollar.el in Emacs or GNU ELPA?
Thank you all and
best regards,
Adrián.
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], (continued)
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Richard Stallman, 2020/05/10
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Phillip Lord, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Richard Stallman, 2020/05/11
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Joost Kremers, 2020/05/12
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Stefan Monnier, 2020/05/12
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Phillip Lord, 2020/05/12
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Stefan Monnier, 2020/05/12
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Phillip Lord, 2020/05/12
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Stefan Monnier, 2020/05/12
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Jonas Bernoulli, 2020/05/13
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs],
Adrián Medraño Calvo <=
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Göktuğ Kayaalp, 2020/05/14
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Richard Stallman, 2020/05/14
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Phillip Lord, 2020/05/15
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Richard Stallman, 2020/05/17
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Stefan Monnier, 2020/05/18
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Adrián Medraño Calvo, 2020/05/18
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Stefan Monnier, 2020/05/18
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Lars Ingebrigtsen, 2020/05/19
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Bastien, 2020/05/22
- Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Joost Kremers, 2020/05/18