# List manipulation problem

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?

-
 You could do something like Transpose[Thread /@ Thread[{v, Transpose[u]}]] – Leonid Shifrin Jan 7 at 17:37 Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign – Vitaliy Kaurov Jan 8 at 13:38

This works:

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

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

-
 Perfect thanks I didn't think about Transpose – su1 Jan 8 at 8:44

Another possibility using Outer:

Outer[Composition[Transpose, List], {v}, u, 1][[1]]

(* {{{0, 1}, {4, 3}}, {{0, 2}, {4, 6}}, {{0, 3}, {4, 9}}} *)

-

Still another way, using rule-based expression rewriting.

u /. {i_, j_} -> {{v[[1]], i}, {v[[2]]}, j}


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

-
Inner[List, v, #, List] & /@ u

(*  {{{0, 1}, {4, 3}}, {{0, 2}, {4, 6}}, {{0, 3}, {4, 9}}}  *)

-
Transpose /@ Tuples[{{v}, u}]
Transpose @@@ Table[{j, i}, {i, u}, {j, {v}}]
Transpose /@ Partition[Riffle[u, {v}, {1, -2, 2}], 2]

(*{{{0, 1}, {4, 3}}, {{0, 2}, {4, 6}}, {{0, 3}, {4, 9}}}*)

-
 +1 for Tuples – Mr.Wizard♦ Jan 8 at 6:46

Just to be different:

Thread /@ ArrayFlatten @ {{v, List /@ u}}

`