Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1996

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

Search the Archive

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] ====


  • Prev by Date: Modelling T-Bond futures options on Mathematica
  • Next by Date: Re: Notebook printing on unix?
  • Previous by thread: How do you parse a n element list into a 2 by (n/2) array?
  • Next by thread: Re: Mma 2.2.3 / Win95 - PROBLEM