Re: newbie: all possible sums of two lists
- To: mathgroup at smc.vnet.net
- Subject: [mg30675] Re: [mg30657] newbie: all possible sums of two lists
- From: BobHanlon at aol.com
- Date: Sat, 8 Sep 2001 02:22:15 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 2001/9/3 9:12:22 PM, alantu at students.uiuc.edu writes: >Hello, I confess I am a newbie to Mathematica. I think I have a basic >understanding of the syntax and concepts, but there are just so many >functions. What is the most efficient way to find all the possible sums >of >two lists. > >List[i1, i2, ... i_n] >List[j1, j2, ... j_m] > >I want > >List[i1+j1, i1+j2, i1+j3, ... i1+j_m, i2+j1, i2+j2, i2+j3, ... i2+j_m, >... >i_n+j_m] > iL = {i1, i2, i3, i4}; jL = {j1, j2, j3}; Flatten[Outer[Plus, iL, jL]] {i1 + j1, i1 + j2, i1 + j3, i2 + j1, i2 + j2, i2 + j3, i3 + j1, i3 + j2, i3 + j3, i4 + j1, i4 + j2, i4 + j3} Bob Hanlon Chantilly, VA USA