help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: member returns list


From: Michael Heerdegen
Subject: Re: member returns list
Date: Wed, 02 Sep 2015 18:45:14 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux)

Emanuel Berg <embe8573@student.uu.se> writes:

> Or is it something else?

The `car' of the result of `member' is the actual element you were
searching.  Since `member' tests with `equal', that can be a different
object.  So it can be useful to have access to it.

But `member' returns a whole sublist.  This gives you also a simple mean
to modify a list, like in this example:

(let ((list '(1 2 3 4 5)))
  (let ((list1 (member 3 list)))
    (when list1 (setcar list1 -3))
    list))

   ==> (1 2 -3 4 5)


Michael.




reply via email to

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