Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13089 > unrolled thread
| Started by | hknetman <hknetman@hotmail.com> |
|---|---|
| First post | 2013-01-11 02:38 +0000 |
| Last post | 2013-01-12 03:24 +0000 |
| Articles | 4 — 3 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
List:{1}, {2,3},{4,5,6}.... hknetman <hknetman@hotmail.com> - 2013-01-11 02:38 +0000
Re: List:{1}, {2,3},{4,5,6}.... "Moses, Peter J. C." <mows@mopar.freeserve.co.uk> - 2013-01-12 03:22 +0000
Re: List:{1}, {2,3},{4,5,6}.... Ray Koopman <koopman@sfu.ca> - 2013-01-12 03:23 +0000
Re: List:{1}, {2,3},{4,5,6}.... Ray Koopman <koopman@sfu.ca> - 2013-01-12 03:24 +0000
| From | hknetman <hknetman@hotmail.com> |
|---|---|
| Date | 2013-01-11 02:38 +0000 |
| Subject | List:{1}, {2,3},{4,5,6}.... |
| Message-ID | <kcntv4$f8h$1@smc.vnet.net> |
I use the command
list = Table[i + 1, {n, 1, 5}, {i, n (n - 1)/2, n (n - 1)/2 + n - 1}]
to get the following result:
{{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}
Is there any better method?
Thanks a lot.
[toc] | [next] | [standalone]
| From | "Moses, Peter J. C." <mows@mopar.freeserve.co.uk> |
|---|---|
| Date | 2013-01-12 03:22 +0000 |
| Message-ID | <kcqkue$lpo$1@smc.vnet.net> |
| In reply to | #13089 |
Hi "hknetman",
Here is another way ...
Range[#]+Accumulate[#-1]&[Range[5]]
Best regards,
Peter.
Peter. J. C. Moses.
Moparmatic Co.
1154 Evesham Road.
Astwood Bank.
Redditch.
Worcs.
B96 6DT.
England.
Tel & Fax 01527 892413.
52°15.713’ N. 001°56.256’ W
"hknetman" <hknetman@hotmail.com> wrote in message
news:kcntv4$f8h$1@smc.vnet.net...
>I use the command
> list = Table[i + 1, {n, 1, 5}, {i, n (n - 1)/2, n (n - 1)/2 + n - 1}]
> to get the following result:
> {{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}
>
> Is there any better method?
>
> Thanks a lot.
>
[toc] | [prev] | [next] | [standalone]
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Date | 2013-01-12 03:23 +0000 |
| Message-ID | <kcql08$lr5$1@smc.vnet.net> |
| In reply to | #13089 |
On Jan 10, 6:38 pm, hknetman <hknet...@hotmail.com> wrote:
> I use the command
> list = Table[i + 1, {n, 1, 5}, {i, n (n - 1)/2, n (n - 1)/2 + n - 1}]
> to get the following result:
> {{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}
>
> Is there any better method?
>
> Thanks a lot.
I'm not sure what "better" means, but
here are the original and two others:
m = 5
Table[i+1,{n,m},{i,n(n-1)/2,n(n-1)/2+n-1}] (* original *)
Table[Range[1+n(n-1)/2,n(n+1)/2],{n,m}] (* clearest ? *)
Range[2+#*#-#,#*#+#,2]/2&/@Range@m (* shortest ? *)
5
{{1},{2,3},{4,5,6},{7,8,9,10},{11,12,13,14,15}}
{{1},{2,3},{4,5,6},{7,8,9,10},{11,12,13,14,15}}
{{1},{2,3},{4,5,6},{7,8,9,10},{11,12,13,14,15}}
[toc] | [prev] | [next] | [standalone]
| From | Ray Koopman <koopman@sfu.ca> |
|---|---|
| Date | 2013-01-12 03:24 +0000 |
| Message-ID | <kcql0j$lra$1@smc.vnet.net> |
| In reply to | #13089 |
On Jan 10, 6:38 pm, hknetman <hknet...@hotmail.com> wrote:
> I use the command
> list = Table[i + 1, {n, 1, 5}, {i, n (n - 1)/2, n (n - 1)/2 + n - 1}]
> to get the following result:
> {{1}, {2, 3}, {4, 5, 6}, {7, 8, 9, 10}, {11, 12, 13, 14, 15}}
>
> Is there any better method?
>
> Thanks a lot.
k = 0; Table[++k,{i,m},{j,i}]
is both clearer and shorter than both my previous suggestions.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web