Hello I have these two lists:
l1={a, b, c} l2={k, l, m}
How can I get
{a, b, c, k, a, b, c, l, a, b, c, m}?
I toyed with Riffle along the line below to no avail
Riffle
Thanks
Riffle[Sequence@l1, l2]
Thanks - your answer suits me. What is the advantage of the infix form compared to the normal form ie ?
Flatten[Join[l1, {#}]] & /@ l2
Thanks I undestood what is going on only by removing the Flatten
Flatten
Special merge of two lists
Slight variation, Join could be faster if it matters:
Flatten[l1~Join~{#} & /@ l2]
{a, b, c, k, a, b, c, l, a, b, c, m}
Hi Wojtek,
this is not very elegant, but it works:
l1 = {a, b, c}; l2 = {k, l, m}; Clear[lll]; Flatten[Thread[{lll, l2}] /. lll -> l1]
Regards -- Henrik
In[12]:= Append[l1, #] & /@ l2 // Flatten Out[12]= {a, b, c, k, a, b, c, l, a, b, c, m}
This maps the pure function which appends an element to l1, onto the elements of l2, and then flattens the resulting list.