/[guile]/guile/guile-core/doc/ref/scheme-compound.texi
ViewVC logotype

Diff of /guile/guile-core/doc/ref/scheme-compound.texi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.14 by kryde, Fri Aug 29 23:06:25 2003 UTC revision 1.15 by kryde, Sat Sep 13 00:12:08 2003 UTC
# Line 372  itself is not modified or used in the re Line 372  itself is not modified or used in the re
372    
373  @rnindex reverse  @rnindex reverse
374  @deffn {Scheme Procedure} reverse lst  @deffn {Scheme Procedure} reverse lst
375    @deffnx {Scheme Procedure} reverse! lst [newtail]
376  @deffnx {C Function} scm_reverse (lst)  @deffnx {C Function} scm_reverse (lst)
377  Return a new list that contains the elements of @var{lst} but  @deffnx {C Function} scm_reverse_x (lst, newtail)
378  in reverse order.  Return a list comprising the elements of @var{lst}, in reverse order.
 @end deffn  
379    
380  @c NJFIXME explain new_tail  @code{reverse} constructs a new list, @code{reverse!} modifies
381  @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.  
382    
383  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
384  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
385  the tail.  Therefore, the @var{lst} symbol to which the head of the  tail.  For @code{scm_reverse_x}, the @var{newtail} parameter is
386  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!}  
387  @end deffn  @end deffn
388    
389  @node List Modification  @node List Modification

Legend:
Removed from v.1.14  
changed lines
  Added in v.1.15

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26