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
.
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}}*)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With