For demonstration purpose,
I have list with has a list:
> (setf x (list '(1 2 1) '(4 5 4)))
((1 2 1) (4 5 4))
> (length x)
2
I want to add a new list ‘(2 3 2) to it. The append function:
> (append '(2 3 2) x)
(2 3 2 (1 2 1) (4 5 4))
> (length (append '(2 3 2) x))
5
isn’t really doing what I want.
What I want is to add ‘(2 3 2) like this:
((8 7 8) (1 2 1) (4 5 4))
so that the length is 3.
So far, I haven’t seen any example or ways to do what I want. Is there a built-in function or effective way of doing this ?
APPEND is not a destructive function, which is what you are asking for. What APPEND does is allocate a new list, which it then returns.
What you can do to achieve your goals is:
(setf x (append '((...)) x)) ;;appends the quoted list to xThere is also the function NCONC, which adjusts pointers destructively.
For your meditations, I present example work: