[Top][All Lists]

[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 <address@hidden> wrote:

> Marcin Borkowski <address@hidden> 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))))
--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.


Marcin Borkowski
Faculty of Mathematics and Computer Science
Adam Mickiewicz University

reply via email to

[Prev in Thread] Current Thread [Next in Thread]