[Top][All Lists]

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

Re: replacing a certain element in a list with another

From: Barry Margolin
Subject: Re: replacing a certain element in a list with another
Date: Fri, 24 Oct 2003 15:06:48 GMT

In article <>,
Roland Winkler  <> wrote:
>The info node Rearrangement in the elisp manual says:
> - Function: nreverse list
>     This function reverses the order of the elements of LIST.  Unlike
>     `reverse', `nreverse' alters its argument by reversing the CDRs in
>     the cons cells forming the list.  The cons cell that used to be
>     the last one in LIST becomes the first cons cell of the value.
>     For example:
>          (setq x '(a b c))
>               => (a b c)
>          x
>               => (a b c)
>          (nreverse x)
>               => (c b a)
>          ;; The cons cell that was first is now last.
>          x
>               => (a)
>The last two lines I find confusing because they use the argument of
>nreverse after it was passed to nreverse. (They gave rise to my

Just to illustrate the danger of continuing to use it without re-assigning
it.  Typically you would write:

(setq x (nreverse x))

if you intended to keep using that variable.

>question whether the argument of nreverse could be used for anything
>"useful" after it was passed to nreverse.) Instead, the info node
>could use the same sentence that is used in the docstring of nreverse:
>    Returns the beginning of the reversed list.

What a function returns is called its "value".  So isn't this what is
described in the last sentence of the description?

Barry Margolin,
Level(3), Woburn, MA
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.

reply via email to

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