* doc/lispref/sequences.texi (Sequence Functions): Update nreverse.

* src/fns.c (Fnreverse): Accept strings for SEQ and update doc-string.
This commit is contained in:
Leo Liu 2014-05-21 11:49:58 +08:00
parent e619d93c22
commit 254b7645f3
4 changed files with 18 additions and 8 deletions

View file

@ -1,3 +1,7 @@
2014-05-21 Leo Liu <sdl.web@gmail.com>
* sequences.texi (Sequence Functions): Update nreverse.
2014-05-19 Paul Eggert <eggert@cs.ucla.edu>
Allow any non-nil value to count as true in bool-vector.

View file

@ -261,13 +261,16 @@ x
@end defun
@defun nreverse seq
@cindex reversing a string
@cindex reversing a list
@cindex reversing a vector
This function reverses the order of the elements of @var{seq}.
If @var{seq} is a list, @code{nreverse} alters its by reversing the @sc{cdr}s
If @var{seq} is a list, @code{nreverse} alters it by reversing the @sc{cdr}s
in the cons cells. The cons cell that used to be the last one in @var{seq}
becomes the first cons cell of the value. If @var{seq} is a vector or
bool vector, its items are placed in the same vector in a reversed order.
bool vector, its items are placed in the same vector in a reversed
order. If @var{seq} is a string, it works like @code{reverse} i.e., no
destructive modifcation in preference to treat strings as immutable.
For example:

View file

@ -1,3 +1,7 @@
2014-05-21 Leo Liu <sdl.web@gmail.com>
* fns.c (Fnreverse): Accept strings for SEQ and update doc-string.
2014-05-20 Michael Albinus <michael.albinus@gmx.de>
* dbusbind.c (xd_signature): Revert last 2 patches.

View file

@ -1697,16 +1697,15 @@ changing the value of a sequence `foo'. */)
}
DEFUN ("nreverse", Fnreverse, Snreverse, 1, 1, 0,
doc: /* Reverse order of items in a list or vector SEQ.
If SEQ is a list, it should be nil-terminated, and reversed
by modifying cdr pointers. Return the reversed SEQ.
Note that unlike `reverse', this function doesn't work with strings.
It is strongly encouraged to treat them as immutable. */)
doc: /* Reverse order of items in a list, vector or string SEQ.
If SEQ is a list, it should be nil-terminated.
This function may destructively modify SEQ to produce the value. */)
(Lisp_Object seq)
{
if (NILP (seq))
return seq;
else if (STRINGP (seq))
return Freverse (seq);
else if (CONSP (seq))
{
Lisp_Object prev, tail, next;