Re: direct product of two sets
- To: mathgroup at smc.vnet.net
- Subject: [mg53284] Re: direct product of two sets
- From: simon.anders at uibk.ac.at
- Date: Tue, 4 Jan 2005 03:13:26 -0500 (EST)
- References: <crb4hv$an3$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi,
> Give 2 finite sets A and B, how can I compute their direct product
> A x B := {(a,b) : a\in A, b\in B}
>
> Can someone help me?
Use Outer:
In[1] := a = {1, 3, 5}; b = {2, 4, 6, 8};
In[2] := Outer [{#1, #2} &, a, b]
Out[2] := {{{1, 2}, {1, 4}, {1, 6}, {1, 8}},
{{3, 2}, {3, 4}, {3, 6}, {3, 8}},
{{5, 2}, {5, 4}, {5, 6}, {5, 8}}}
HTH,
Simon