MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: direct product of two sets


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


  • Prev by Date: Re: direct product of two sets
  • Next by Date: Re: direct product of two sets
  • Previous by thread: Re: direct product of two sets
  • Next by thread: Re: direct product of two sets