MathGroup Archive 2011

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

Search the Archive

Re: How to create such a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg118493] Re: How to create such a list
  • From: Heike Gramberg <heike.gramberg at gmail.com>
  • Date: Fri, 29 Apr 2011 07:35:27 -0400 (EDT)

One option would be

f[w_, n_] :=
 Apply[Plus, Subsets[Map[w, Range[n]]], {1}]

f[x,3]


output:
{0, w[1], w[2], w[3], w[1] + w[2], w[1] + w[3], w[2] + w[3], w[1] + w[2] + w[3]}

Heike


On 28 Apr 2011, at 11:37, Dominic Woerner wrote:

> Hi,
>
> I like to create a list of the form:
> 0,w[1],...,w[n],w[1]+w[2],...,w[1]+w[n],w[2]+w[3],......,w[1]+...+w[n]
> for arbitrary n
> Is there a neat way to do this?
>
> Cheers,
> Dominic
>


  • Prev by Date: HoldAll/HoldRest // updated
  • Next by Date: Re: Workaround for Plot[ ] and color via PlotStyle
  • Previous by thread: Re: How to create such a list
  • Next by thread: Re: How to create such a list