Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1999 > unrolled thread
| Started by | Heike Gramberg <heike.gramberg@gmail.com> |
|---|---|
| First post | 2011-04-29 11:35 +0000 |
| Last post | 2011-04-29 11:35 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.soft-sys.math.mathematica
Re: How to create such a list Heike Gramberg <heike.gramberg@gmail.com> - 2011-04-29 11:35 +0000
| From | Heike Gramberg <heike.gramberg@gmail.com> |
|---|---|
| Date | 2011-04-29 11:35 +0000 |
| Subject | Re: How to create such a list |
| Message-ID | <ipe7pk$r45$1@smc.vnet.net> |
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
>
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web