Re: Partition Help

• To: mathgroup at smc.vnet.net
• Subject: [mg126546] Re: Partition Help
• From: Bob Hanlon <hanlonr357 at gmail.com>
• Date: Fri, 18 May 2012 05:26:08 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• References: <201205170808.EAA05007@smc.vnet.net>

```data = Array[a, {3, 6}]

{{a[1, 1], a[1, 2], a[1, 3], a[1, 4], a[1, 5], a[1, 6]}, {a[2, 1],
a[2, 2], a[2, 3], a[2, 4], a[2, 5], a[2, 6]}, {a[3, 1], a[3, 2],
a[3, 3], a[3, 4], a[3, 5], a[3, 6]}}

Partition[#, 3] & /@ data

{{{a[1, 1], a[1, 2], a[1, 3]}, {a[1, 4], a[1, 5],
a[1, 6]}}, {{a[2, 1], a[2, 2], a[2, 3]}, {a[2, 4], a[2, 5],
a[2, 6]}}, {{a[3, 1], a[3, 2], a[3, 3]}, {a[3, 4], a[3, 5],
a[3, 6]}}}

% ==
Map[Flatten,
Partition[data, {1, 3}], {2}] ==
(Flatten[#, 1] & /@
Partition[data, {1, 3}])

True

Bob Hanlon

On Thu, May 17, 2012 at 4:08 AM,  <sierrahotel71 at gmail.com> wrote:
> I'm getting an extra set of braces when trying to partition a matrix and don't understand how to correctly write the function or remove the extra braces.
>
> data = (*Imported 6 column table*)
> d1 = Partition[data, {1, 3}]
> which results in {{{{-45000000, -10, 0}}, {{-419, 0, 1344}}},.....
> I need it to be
> {{{-45000000, -10, 0}, {-419, 0, 1344}},.......
>
> Any help appreciated
>

```

• Prev by Date: Re: unexpected behaviour of Sum
• Next by Date: Re: Coefficient
• Previous by thread: Partition Help
• Next by thread: Re: Partition Help