3

I was wondering how in Mathematica to start with two lists f=[1,2,3] g=[4,5,6] and find the list h= f X g which contains all possible pairs {a,b} such that a is an element of f and b is an element of g.

4

1 回答 1

5
f = {1, 2, 3}; g = {4, 5, 6};
Tuples@{f, g}

(*{{1, 4}, {1, 5}, {1, 6}, {2, 4}, {2, 5}, {2, 6}, {3, 4}, {3, 5}, {3, 6}}*)
于 2013-06-17T15:41:26.253 回答