[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How to quote a list of functions?
From: |
Marcin Borkowski |
Subject: |
Re: How to quote a list of functions? |
Date: |
Wed, 19 Aug 2015 16:22:52 +0200 |
On 2015-08-19, at 02:34, Emanuel Berg <embe8573@student.uu.se> wrote:
> Marcin Borkowski <mbork@mbork.pl> writes:
>
>> Mhm. Imagine that you write a function operating on
>> (general) lists (like `car'). (There are plenty of
>> Lisp functions acting on lists as such, some of them
>> not implemented in Elisp, so you might want to write
>> one yourself in real life.)
>>
>> Now, what would you call the argument of such
>> function, given that `list' is a Lisp function?
>
> Imagine I do WHAT?
As I wrote: Imagine that you write a function operating on (general)
lists. For instance, `car' is such a function: it takes (any) list as
an argument (well, for the empty one it signals an error). Another
example: some time ago I needed a `flatten' function, absent from Elisp,
so I took one from message.el. (I would bet that such a function is
defined in a lot of Elisp libraries, which is another story.)
--8<---------------cut here---------------start------------->8---
(defun flatten-list (list)
"Return a new, flat list that contains all elements of LIST.
\(flatten-list '(1 (2 3 (4 5 (6))) 7))
=> (1 2 3 4 5 6 7)
Taken from message.el."
(cond ((consp list)
(apply #'append (mapcar #'flatten-list list)))
(list
(list list))))
--8<---------------cut here---------------end--------------->8---
Calling the argument of this function `list' seems natural, and has an
added benefit that the second `cond' clause looks quite cute.
Best,
--
Marcin Borkowski
http://octd.wmi.amu.edu.pl/en/Marcin_Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University
- get all functions (was: Re: How to quote a list of functions?), (continued)
- Message not available
- Re: How to quote a list of functions?, Pascal J. Bourguignon, 2015/08/18
- Message not available
- Re: How to quote a list of functions?, Pascal J. Bourguignon, 2015/08/17
- Re: How to quote a list of functions?, Emanuel Berg, 2015/08/18
- Message not available
- Re: How to quote a list of functions?, Pascal J. Bourguignon, 2015/08/16
- Re: How to quote a list of functions?, tomas, 2015/08/17
- Re: How to quote a list of functions?, Emanuel Berg, 2015/08/17
- Re: How to quote a list of functions?, Marcin Borkowski, 2015/08/18
- Re: How to quote a list of functions?, Emanuel Berg, 2015/08/18
- Re: How to quote a list of functions?,
Marcin Borkowski <=
- Re: How to quote a list of functions?, tomas, 2015/08/19
- Re: How to quote a list of functions?, Emanuel Berg, 2015/08/21
- Message not available
- Re: How to quote a list of functions?, Pascal J. Bourguignon, 2015/08/21
- Re: How to quote a list of functions?, Emanuel Berg, 2015/08/21
- Message not available
- Re: How to quote a list of functions?, Pascal J. Bourguignon, 2015/08/21
- Re: How to quote a list of functions?, Emanuel Berg, 2015/08/23
- Re: How to quote a list of functions?, Emanuel Berg, 2015/08/23
- Message not available
- Re: How to quote a list of functions?, Pascal J. Bourguignon, 2015/08/23
- Re: How to quote a list of functions?, Emanuel Berg, 2015/08/24
- Re: How to quote a list of functions?, Emanuel Berg, 2015/08/24