1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-22 20:40:29 +02:00

(Append/Reverse): Merge append and append!,

shown parameters as lst1 ... lstN, describe list argument for
scm_append and scm_append_x and note that it's unmodified.
This commit is contained in:
Kevin Ryde 2003-08-29 23:06:25 +00:00
parent 05c4ffe1a7
commit 697039a9d6

View file

@ -340,32 +340,34 @@ pairs. This is why you should be careful when using the side-effecting
variants. variants.
@rnindex append @rnindex append
@deffn {Scheme Procedure} append . args @deffn {Scheme Procedure} append lst1 @dots{} lstN
@deffnx {C Function} scm_append (args) @deffnx {Scheme Procedure} append! lst1 @dots{} lstN
Return a list consisting of the elements the lists passed as @deffnx {C Function} scm_append (lstlst)
arguments. @deffnx {C Function} scm_append_x (lstlst)
Return a list comprising all the elements of lists @var{lst1} to
@var{lstN}.
@lisp @lisp
(append '(x) '(y)) @result{} (x y) (append '(x) '(y)) @result{} (x y)
(append '(a) '(b c d)) @result{} (a b c d) (append '(a) '(b c d)) @result{} (a b c d)
(append '(a (b)) '((c))) @result{} (a (b) (c)) (append '(a (b)) '((c))) @result{} (a (b) (c))
@end lisp @end lisp
The resulting list is always newly allocated, except that it
shares structure with the last list argument. The last The last argument @var{lstN} may actually be any object; an improper
argument may actually be any object; an improper list results list results if the last argument is not a proper list.
if the last argument is not a proper list.
@lisp @lisp
(append '(a b) '(c . d)) @result{} (a b c . d) (append '(a b) '(c . d)) @result{} (a b c . d)
(append '() 'a) @result{} a (append '() 'a) @result{} a
@end lisp @end lisp
@end deffn
@deffn {Scheme Procedure} append! . lists @code{append} doesn't modify the given lists, but the return may share
@deffnx {C Function} scm_append_x (lists) structure with the final @var{lstN}. @code{append!} modifies the
A destructive version of @code{append} (@pxref{Pairs and given lists to form its return.
lists,,,r5rs, The Revised^5 Report on Scheme}). The cdr field
of each list's final pair is changed to point to the head of For @code{scm_append} and @code{scm_append_x}, @var{lstlst} is a list
the next list, so no consing is performed. Return a pointer to of the list operands @var{lst1} @dots{} @var{lstN}. That @var{lstlst}
the mutated list. itself is not modified or used in the return.
@end deffn @end deffn
@rnindex reverse @rnindex reverse