Skip to main content

Distributing elements across a list of lists


I have two lists:


u = {{1, 3}, {2, 6}, {3, 9}}
v = {0, 4}

and I want to obtain this list from them:


z = {{{0, 1}, {4, 3}}, {{0, 2}, {4, 6}}, {{0, 3},{4, 9}}}


I guess the solution will make use of Map, Thread, or even MapThread but I've tried every combinaison I can think of with no luck. How can I do it?



Answer



This works:


Transpose[{v, #}] & /@ u


{{{0, 1}, {4, 3}}, {{0, 2}, {4, 6}}, {{0, 3}, {4, 9}}}

Comments