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

MathGroup Archive 2008

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

Search the Archive

Re: Convert Array to Simple List

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86995] Re: [mg86940] Convert Array to Simple List
  • From: Murray Eisenberg <murray at math.umass.edu>
  • Date: Fri, 28 Mar 2008 03:17:07 -0500 (EST)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <200803271315.IAA19529@smc.vnet.net>
  • Reply-to: murray at math.umass.edu

If the elements a,b,c,d are themselves _not_ lists, then:

   Flatten[{{a, b}, {c, d}}]
{a, b, c, d}
   Flatten[Transpose[{{a, b}, {c, d}}]]
{a, c, b, d}

If, however, the elements may themselves be lists (and possibly nested 
lists), then you may want to use an additional argument to Flatten, e.g.:

   Flatten[{{a, {b1, b2}}, {c, d}}, 1]
{a, {b1, b2}, c, d}

Unless what you want in this case is also just one level of list; then:

   Flatten[{{a, {b1, b2}}, {c, d}}]
{a, b1, b2, c, d}

Pierre wrote:
> I need to convert an Array (List of List) to a simple List by concatening the colums or the lines.
> 
> e.g. : {{a,b},{c,d}}  ==>{a,b,c,d}
> or
> {{a,b},{c,d}}  ==>{a,c,b,d}
> 

-- 
Murray Eisenberg                     murray at math.umass.edu
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305


  • Prev by Date: Re: FindMinimum[Print[]]
  • Next by Date: Re: Re: Limit[(x - Log[Cosh ]) SinIntegral , x -> Infinity]
  • Previous by thread: Re: Convert Array to Simple List
  • Next by thread: Re: Convert Array to Simple List