[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: |
Phillip Lord |
Subject: |
Re: dash.el [was: Re: Imports / inclusion of s.el into Emacs] |
Date: |
Tue, 12 May 2020 18:21:36 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.91 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> In Clojure, a function literal is written with `#(...)`, and it supports
>> `%n` for arguments, where n=1,2,3...
>
> IIRC there's a macro somewhere providing a similar facility.
> We can't use (# ...) because the reader doesn't like `#` on its own (it
> expects it to be followed by something like a vector, a hex/binary/octal
> number, etc...).
It's not hard to do in a cheesy way. Implemented with dash.el, entirely
from a sense of mischievousness.
(defmacro fn (&rest args)
(let ((argsd
(--tree-map
(cl-case it
('% 'x)
(t it))
args)))
`(lambda (x) ,@args)))
Obviously this is not fully functional, but it works for the trivial example.
(funcall (fn %) 10)
(funcall (fn (+ 10 (/ % 2))) 50)
I can't get it to work from first position though. So:
((lambda (x) x) 10)
works, while
((fn %) 10)
doesn't.
Phil
- 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], Stefan Monnier, 2020/05/10
- RE: dash.el [was: Re: Imports / inclusion of s.el into Emacs], Drew Adams, 2020/05/10
- 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], 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 <=
- 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, 2020/05/14
- 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