MathGroup Archive 2001

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

Search the Archive

Re: newbie: all possible sums of two lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg30691] Re: newbie: all possible sums of two lists
  • From: "Stephen P Luttrell" <luttrell at signal.dra.hmg.gb>
  • Date: Sat, 8 Sep 2001 02:22:38 -0400 (EDT)
  • Organization: Defence Evaluation & Research Agency
  • References: <9n17po$24b$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

"Alan Tu" <alantu at students.uiuc.edu> wrote in message
news:9n17po$24b$1 at smc.vnet.net...
> 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]

Here is an example of what you want to do:

list1 = {i1, i2, i3};
list2 = {j1, j2};
Outer[Plus, list1, list2] // Flatten

--
Stephen P Luttrell
QinetiQ, Malvern, U.K.




  • Prev by Date: Re: newbie: all possible sums of two lists
  • Next by Date: Re: thickness and fonts of axes & labels
  • Previous by thread: Re: newbie: all possible sums of two lists
  • Next by thread: Re: newbie: all possible sums of two lists