Re: Plus sets in mathematica..?

*To*: mathgroup at smc.vnet.net*Subject*: [mg75970] Re: Plus sets in mathematica..?*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Mon, 14 May 2007 03:40:25 -0400 (EDT)*Organization*: The Open University, Milton Keynes, UK*References*: <f26ocl$4tn$1@smc.vnet.net>

changbo wrote: > I want to make a function "f", its domain is every thinkable two sets, and the result is {a+b | aâ??A,bâ??B} 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}. > > How can I construct function "f"? Let me know the source.. Thank you very much One possible way is the following: In[1]:= A = {1, 2, 3}; B = {40, 50, 60, 70}; f[a_, b_] := Flatten[Outer[Plus, b, a]] f[A, B] Out[4]= {41, 42, 43, 51, 52, 53, 61, 62, 63, 71, 72, 73} Regards, Jean-Marc