Append list as not one.

Append list as not one.

Anonymous
Not applicable
781 Views
5 Replies
Message 1 of 6

Append list as not one.

Anonymous
Not applicable

Hello

I get still terrible in my works.

Anyway, all I want to need helping is that if I have some list variable, I want to append list variable individually.

If i use append function such as (setq A(append '( 1 2) ' ( 4 5))), then i will get A that is '(1 2 4 5). However, this is not I want.

I want to get A that is ('(1 2) '(4 5)).

Thanks.

0 Likes
782 Views
5 Replies
Replies (5)
Message 2 of 6

john.uhden
Mentor
Mentor
(append A (list B))

John F. Uhden

0 Likes
Message 3 of 6

ВeekeeCZ
Consultant
Consultant

(append '((1 2)) '((4 5)))

0 Likes
Message 4 of 6

dbroad
Mentor
Mentor

I think you're using the wrong function. Try cons

(setq a (cons '(4 5) nil))
(setq a (cons '(1 2) a))

The results are:

((4 5))

and

((1 2) (4 5))

 

Results should never include the quote function IMO.

 

Architect, Registered NC, VA, SC, & GA.
0 Likes
Message 5 of 6

john.uhden
Mentor
Mentor
Okay then...
(append B (list A)) 😉

You know that I agree with consing over appending. Just having fun.

John F. Uhden

0 Likes
Message 6 of 6

phanaem
Collaborator
Collaborator
(list '(1 2) '(3 4)) = ((1 2) (3 4))