Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #1958 > unrolled thread
| Started by | Dominic Woerner <dominic.woerner@mpi-hd.mpg.de> |
|---|---|
| First post | 2011-04-28 10:37 +0000 |
| Last post | 2011-04-29 11:29 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
How to create such a list Dominic Woerner <dominic.woerner@mpi-hd.mpg.de> - 2011-04-28 10:37 +0000
Re: How to create such a list Peter Breitfeld <phbrf@t-online.de> - 2011-04-29 11:35 +0000
Re: How to create such a list Stefan <wutchamacallit27@gmail.com> - 2011-04-29 11:29 +0000
| From | Dominic Woerner <dominic.woerner@mpi-hd.mpg.de> |
|---|---|
| Date | 2011-04-28 10:37 +0000 |
| Subject | How to create such a list |
| Message-ID | <ipbg0i$agm$1@smc.vnet.net> |
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
[toc] | [next] | [standalone]
| From | Peter Breitfeld <phbrf@t-online.de> |
|---|---|
| Date | 2011-04-29 11:35 +0000 |
| Message-ID | <ipe7qa$r4n$1@smc.vnet.net> |
| In reply to | #1958 |
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
>
Try this:
wArr[s_,e_]:=Array[w,e-s+1,s]
createList[n_]:=Table[wArr[i,n],{i,0,n}]//Flatten
createList[4]
Out=
{w[0], w[1], w[2], w[3], w[4], w[1], w[2], w[3], w[4], w[2], w[3],
w[4], w[3], w[4], w[4]}
--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de
[toc] | [prev] | [next] | [standalone]
| From | Stefan <wutchamacallit27@gmail.com> |
|---|---|
| Date | 2011-04-29 11:29 +0000 |
| Message-ID | <ipe7f9$qr0$1@smc.vnet.net> |
| In reply to | #1958 |
On Apr 28, 6:37 am, Dominic Woerner <dominic.woer...@mpi-hd.mpg.de>
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
I believe this is what you're looking for:
With[{n = 5}, Table[Sum[w[i], {i, 1, k}], {k, 0, n}]]
-Stefan Salanski
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web