Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2013

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

Search the Archive

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

  • To: mathgroup at smc.vnet.net
  • Subject: [mg129418] Re: List:{1}, {2,3},{4,5,6}....
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Fri, 11 Jan 2013 22:27:04 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-newout@smc.vnet.net
  • Delivered-to: mathgroup-newsend@smc.vnet.net
  • References: <kcntv4$f8h$1@smc.vnet.net>

On Jan 10, 6:38 pm, hknetman <hknet... at 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}}



  • Prev by Date: Re: List:{1}, {2,3},{4,5,6}....
  • Next by Date: Re: Has anyone got code for a Smith Chart?
  • Previous by thread: Re: List:{1}, {2,3},{4,5,6}....
  • Next by thread: Re: List:{1}, {2,3},{4,5,6}....