Re: Partition a list based on columns
- To: mathgroup at smc.vnet.net
- Subject: [mg119665] Re: Partition a list based on columns
- From: Ray Koopman <koopman at sfu.ca>
- Date: Fri, 17 Jun 2011 00:06:31 -0400 (EDT)
- References: <itcdai$d13$1@smc.vnet.net>
On Jun 16, 1:02 am, StatsMath <stats.ma... at gmail.com> wrote: > [...] > > What would be a good way to line up elements in a list in a diagonal > fashion, for ex: from Range[9] want to create the follwing matrix: > > 1 2 4 > 3 5 7 > 6 8 9 This is better than my previous suggestion: m[n_] := Partition[FoldList[Plus,0,Join[Range[n-1],Range[n-1,1,-1]]], n, 1] + Range[n]
- Follow-Ups:
- Re: Partition a list based on columns
- From: DrMajorBob <btreat1@austin.rr.com>
- Re: Partition a list based on columns