[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 <m3ptgmdet4.fsf@tfkp07.physik.uni-erlangen.de>,
Roland Winkler <Roland.Winkler@physik.uni-erlangen.de> 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, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
- Re: replacing a certain element in a list with another, Kai Grossjohann, 2003/10/16
- Re: replacing a certain element in a list with another, Roland Winkler, 2003/10/22
- Re: replacing a certain element in a list with another, Barry Margolin, 2003/10/22
- Re: replacing a certain element in a list with another, Barry Margolin, 2003/10/23
- Re: replacing a certain element in a list with another, Roland Winkler, 2003/10/23
- Re: replacing a certain element in a list with another, Barry Margolin, 2003/10/23
- Re: replacing a certain element in a list with another, Roland Winkler, 2003/10/24
- Re: replacing a certain element in a list with another,
Barry Margolin <=
- Re: replacing a certain element in a list with another, Oliver Scholz, 2003/10/25