tconc
tconc(l_ptrg_x) =>l_result
Description
Creates a list cell whose car points to a list of the elements being constructed and whose cdr points to the last list cell of the list being constructed.
A tconc structure is a special type of list that allows efficient addition of objects to the end of a list. It consists of a list cell whose car points to a list of the elements being constructed with tconc and whose cdr points to the last list cell of the list being constructed. If l_ptr is nil, a new tconc structure is automatically created. To obtain the list under construction, take the car of the tconc structure.
tconc and lconc are much faster than append when adding new elements to the end of a list. The append function is much slower, because it traverses and copies the list to reach the end, whereas tconc and lconc only manipulate pointers.
Arguments
|
A |
|
Value Returned
|
Returns l_ptr, which must be a |
Examples
x = tconc(nil 1) ; x is now ((1) 1)
tconc(x 2) ; x is now ((1 2) 2)
tconc(x 3) ; x is now ((1 2 3) 3)
x = car(x) ; x is now (1 2 3)
x now equals (1 2 3), the desired result.
Related Topics
Return to top