I have two lists.
l1={
{"Mn", "Mn1", 1., "B", 1.4},
{"Al", "Al1", 1., "B", 1.4}
};
l2={
{{1, 1, 0.}, {11, 11, 0.}},
{{2, 2, 0.}, {22, 22, 0.}, {222, 222, 0.}}
}
This is a short version of the lists. The two lists always have the same Length
so that their level-1 elements have a one-to-one relation. However, the elements of l2
can have varying Length
as shown here.
I'd like to generate a new list as follows.
l3=
{
{"Mn", "Mn1", {1, 1, 0.}, 1., "B", 1.4},
{"Mn", "Mn1", {11, 11, 0.}, 1., "B", 1.4},
{"Al", "Al1", {2, 2, 0.}, 1., "B", 1.4},
{"Al", "Al1", {22, 22, 0.}, 1., "B", 1.4},
{"Al", "Al1", {222, 222, 0.}, 1., "B", 1.4}
}
I think MapThread
might be the direction to go, but I cannot think of any function to obtain the result. I'm not stick to MapThread
. Any function that can do the job is okay as long as it's a vertorization method since that's what MMA favors.
Thank you.
l3
for English isn't my first language. That's why I use newlines to separate elements ofl1
andl2
and change values ofl2
to1,11
and2, 22, 222
for clarity. Maybe you could help me with that. But I think the answers provided understood my need and returns the desired format ofl3
. Also, I appreciate the suggestions ofl1/2/3
may not be a good variable name. Thanks. $\endgroup$