Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #13109 > unrolled thread

Re: List:{1}, {2,3},{4,5,6}....

Started byBob Hanlon <hanlonr357@gmail.com>
First post2013-01-12 03:23 +0000
Last post2013-01-12 03:23 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: List:{1}, {2,3},{4,5,6}.... Bob Hanlon <hanlonr357@gmail.com> - 2013-01-12 03:23 +0000

#13109 — Re: List:{1}, {2,3},{4,5,6}....

FromBob Hanlon <hanlonr357@gmail.com>
Date2013-01-12 03:23 +0000
SubjectRe: List:{1}, {2,3},{4,5,6}....
Message-ID<kcql03$lr3$1@smc.vnet.net>
m = 5;

t1 = Timing[
   list1 = Table[
      i + 1, {n, 1, m}, {i, n (n - 1)/2, n (n - 1)/2 + n - 1}];][[1]]

0.000083

t2 = Timing[
   list2 = Table[Range[n (n - 1)/2 + 1, n (n + 1)/2], {n, m}];][[1]]

0.000054

t1/t2

1.5

list1 == list2

True

m = 1000;

t3 = Timing[
   list3 = Table[
      i + 1, {n, 1, m}, {i, n (n - 1)/2, n (n - 1)/2 + n - 1}];][[1]]

0.368475

t4 = Timing[
   list4 = Table[Range[n (n - 1)/2 + 1, n (n + 1)/2], {n, m}];][[1]]

0.010008

t3/t4

36.82

list3 == list4

True


Bob Hanlon


On Thu, Jan 10, 2013 at 9:39 PM, hknetman <hknetman@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.
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web