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: [mg111265] Re: de-nesting complex nested lists
  • From: Ray Koopman <koopman at sfu.ca>
  • Date: Sun, 25 Jul 2010 07:46:07 -0400 (EDT)
  • References: <i2gjui$am$1@smc.vnet.net>

On Jul 24, 11:00 pm, Michael Stern <nycst... at gmail.com> 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

f[a_] := If[VectorQ[a],a,Sequence@@(f/@a)]

f /@ {{1,2,3}, {1,2,4}, {{1,2,3,4}, {1,2,3,8}},
      {{1,2,9}, {{1,2,13}, {4,5,6}}}}

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


  • Prev by Date: Re: Need to align data from sublists to Union of dates
  • Next by Date: Re: de-nesting complex nested lists
  • Previous by thread: de-nesting complex nested lists
  • Next by thread: Re: de-nesting complex nested lists