< Back to IRCAM Forum

Append, x-append, list, sort? combine sublists from two lists in order

Greetings All,

Having tried the above functions (listed in the topic title, and more!) to combine, in order, the following example lists:

((1 2 3) (2 1 3) (2 3 1)) ((4 5) (5 4) (4 5))

to produce

((1 2 3 4 5) (2 1 3 5 4) (2 3 1 4 5))

I’ve only been able to arrive at very cumbersome solution using list first, second, third, append to link the firsts etc. from both lists and then using list to group the results.

There must be a simpler and more elegant way to make this type of combination!

Any help would be much appreciated as ever. Thanks!


If you always want the same final combinations a first way to resolve can be the following:

I hope this help, ciao


Final list functions only for visualizing inside textfile class. Probably you have to adjust final part of patch for your aims.

Hello krhes,

as you kind of loop parallel through two (or any number of) lists, mapcar is a very elegant and concise function in lisp.
see also here:


Ciao Fdsdb,

This is very interesting solution and a good example of posn-match. I’ll explore this further as I’m sure it will help I’m other parts of my current project!

Thanks very much,

Dear Peter,

This is certainly an elegant and direct way of solving this problem. I was hoping to use mapcar in some way, and of course using append in lambda is obvious now one sees it (as it always is once someone has pointed it out!).
Many thanks, and much appreciated,

Hi All,

Too hot for thinking! Of course Peter’s solution is very good and general, thank you, I had absolutely misunderstood the question, sorry…


Even more concise …Screenshot_2019-06-30_14-49-47


1 Like

Dear Karim,


Thank you!