Re: How do you parse a n element list into a 2 by (n/2) array?
- To: mathgroup at smc.vnet.net
- Subject: [mg4179] Re: How do you parse a n element list into a 2 by (n/2) array?
- From: ianc (Ian Collier)
- Date: Tue, 11 Jun 1996 00:53:30 -0400
- Organization: Wolfram Research, Inc.
- Sender: owner-wri-mathgroup at wolfram.com
In article <4p8gbp$7d at dragonfly.wolfram.com>, welter at .ti.com (Jason
Welter) wrote:
> I have a list say,
>
> {1,2,3,4,5,6}
>
> and want to transform it to:
>
> {{1,2},{3,4},{5,6}}
>
> I know it's possible but I don't remember how.
You can do what you want using Partition.
In[4]:=
Partition[ {1,2,3,4,5,6}, 2 ]
Out[4]=
{{1,2},{3,4},{5,6}}
See section 1.8.10 of the Mathematica book for more details.
I hope this helps.
--Ian
-----------------------------------------------------------
Ian Collier
Wolfram Research, Inc.
-----------------------------------------------------------
tel:(217)-398-0700 fax:(217)-398-0747 ianc at wolfram.com
Wolfram Research Home Page: http://www.wolfram.com/
-----------------------------------------------------------
==== [MESSAGE SEPARATOR] ====