mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-22 20:40:29 +02:00
(Append/Reverse): Merge reverse and reverse!,
describe newtail parameter for reverse!, remove confusing caveat about head becoming tail for reverse!.
This commit is contained in:
parent
eee36f2105
commit
c537e01bce
1 changed files with 9 additions and 16 deletions
|
@ -372,25 +372,18 @@ itself is not modified or used in the return.
|
||||||
|
|
||||||
@rnindex reverse
|
@rnindex reverse
|
||||||
@deffn {Scheme Procedure} reverse lst
|
@deffn {Scheme Procedure} reverse lst
|
||||||
|
@deffnx {Scheme Procedure} reverse! lst [newtail]
|
||||||
@deffnx {C Function} scm_reverse (lst)
|
@deffnx {C Function} scm_reverse (lst)
|
||||||
Return a new list that contains the elements of @var{lst} but
|
@deffnx {C Function} scm_reverse_x (lst, newtail)
|
||||||
in reverse order.
|
Return a list comprising the elements of @var{lst}, in reverse order.
|
||||||
@end deffn
|
|
||||||
|
|
||||||
@c NJFIXME explain new_tail
|
@code{reverse} constructs a new list, @code{reverse!} modifies
|
||||||
@deffn {Scheme Procedure} reverse! lst [new_tail]
|
@var{lst} in constructing its return.
|
||||||
@deffnx {C Function} scm_reverse_x (lst, new_tail)
|
|
||||||
A destructive version of @code{reverse} (@pxref{Pairs and lists,,,r5rs,
|
|
||||||
The Revised^5 Report on Scheme}). The cdr of each cell in @var{lst} is
|
|
||||||
modified to point to the previous list element. Return a pointer to the
|
|
||||||
head of the reversed list.
|
|
||||||
|
|
||||||
Caveat: because the list is modified in place, the tail of the original
|
For @code{reverse!}, the optional @var{newtail} is appended to to the
|
||||||
list now becomes its head, and the head of the original list now becomes
|
result. @var{newtail} isn't reversed, it simply becomes the list
|
||||||
the tail. Therefore, the @var{lst} symbol to which the head of the
|
tail. For @code{scm_reverse_x}, the @var{newtail} parameter is
|
||||||
original list was bound now points to the tail. To ensure that the head
|
mandatory, but can be @code{SCM_EOL} if no further tail is required.
|
||||||
of the modified list is not lost, it is wise to save the return value of
|
|
||||||
@code{reverse!}
|
|
||||||
@end deffn
|
@end deffn
|
||||||
|
|
||||||
@node List Modification
|
@node List Modification
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue