MathGroup Archive 2010

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

Search the Archive

Re: de-nesting complex nested lists

  • To: mathgroup at smc.vnet.net
  • Subject: [mg111290] Re: de-nesting complex nested lists
  • From: Peter Breitfeld <phbrf at t-online.de>
  • Date: Mon, 26 Jul 2010 06:38:52 -0400 (EDT)
  • References: <i2gjui$am$1@smc.vnet.net>

Michael Stern wrote:

> If one has an irregularly nested list like
>
> {{1, 2, 3}, {1, 2, 4}, {{1, 2, 3, 4}, {1, 2, 3, 8}}, {{1, 2, 9}, {{1,
> 2, 13}, {4, 5, 6}}}},
>
> How might one most easily transform this into a list of uniform Depth
> 2 ( {{1,2,3},{1,2,4},{1,2,3,4},{1,2,3,8},{1,2,9},{1,2,13},{4,5,6}} ) ?
>
> Thanks in advance,
>
> Michael
>

One possibility is to extract the list of vectors like this

ll={{1, 2, 3}, {1, 2, 4}, {{1, 2, 3, 4}, {1, 2, 3, 8}},
     {{1, 2, 9}, {{1, 2, 13}, {4, 5, 6}}}}
     
uniform=Cases[ll,_?VectorQ, Infinity]

Out={{1, 2, 3}, {1, 2, 4}, {1, 2, 3, 4}, {1, 2, 3, 8}, {1, 2, 9},
    {1, 2, 13}, {4, 5, 6}}

-- 
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de


  • Prev by Date: Re: Help with an ODE
  • Next by Date: Re: A Question About Directive
  • Previous by thread: Re: de-nesting complex nested lists
  • Next by thread: Re: de-nesting complex nested lists