Re: Plus sets in mathematica..?
- To: mathgroup at smc.vnet.net
 - Subject: [mg75972] Re: Plus sets in mathematica..?
 - From: Bill Rowe <readnewsciv at sbcglobal.net>
 - Date: Mon, 14 May 2007 03:41:26 -0400 (EDT)
 
On 5/13/07 at 5:54 AM, e-changbo at hanmail.net (changbo) wrote:
>I want to make a function "f", its domain is every thinkable two
>sets, and the result is  {a+b | a=E2=88=88A,b=E2=88=88B} for A,B.
>ex) A={1,2,3}, B={40,50,60,70}, then I have f[A,B] as
>{41,42,43,51,52,53,61,62,63,71,72,73}.
Using Outer with Plus will do the trick, i.e.,
In[10]:= Outer[Plus, Range[40, 70, 10], Range@3]
Out[10]= {{41, 42, 43}, {51, 52, 53}, {61, 62, 63},
    {71, 72, 73}}
and if you need a 1D list used Join or Flatten, i.e,
In[11]:= Join @@ Outer[Plus, Range[40, 70, 10], Range@3]
Out[11]= {41,42,43,51,52,53,61,62,63,71,72,73}
or
In[12]:= Flatten@Outer[Plus, Range[40, 70, 10], Range@3]
Out[12]= {41,42,43,51,52,53,61,62,63,71,72,73}
--
To reply via email subtract one hundred and four