nconc
nconc(l_arg1l_arg2[l_arg3... ] ) =>l_result
Description
Equivalent to a destructive append where the first argument is modified.
This results in nconc being much faster than append but not as fast as tconc and lconc. Thus nconc returns a list consisting of the elements of l_arg1, followed by the elements of l_arg2, followed by the elements of l_arg3, and so on. The cdr of the last list cell of l_argi is modified to point to l_argi+1. Thus caution must be taken because if nconc is called with the l_argi two consecutive times it can form an infinite structure where the cdr of the last list cell of l_argi points to the car of l_argi.
Use the nconc function principally to reduce the amount of memory consumed. A call to append would normally duplicate the first argument whereas nconc does not duplicate any of its arguments, thereby reducing memory consumption.
Arguments
Value Returned
Examples
The following example forms an infinite list structure (a b c d e f g a b c d e f g ...).
x = '(a b c)
nconc( x '(d)) ; x is now (a b c d)
nconc( x '(e f g) ) ; x is now the list (a b c d e f g)
nconc( x x ) ; Forms an infinite structure.
Related Topics
Return to top