Re: de-nesting complex nested lists
- To: mathgroup at smc.vnet.net
- Subject: [mg111270] Re: de-nesting complex nested lists
- From: "David Park" <djmpark at comcast.net>
- Date: Sun, 25 Jul 2010 07:47:05 -0400 (EDT)
- References: <24512621.1280038536627.JavaMail.root@n11>
Two methods: test = {{1, 2, 3}, {1, 2, 4}, {{1, 2, 3, 4}, {1, 2, 3, 8}}, {{1, 2, 9}, {{1, 2, 13}, {4, 5, 6}}}}; Cases[test, {(_?NumericQ) ..}, \[Infinity]] Nest[Map[Sequence @@ # &, #, {-3}] &, test, Depth[test] - 3] David Park djmpark at comcast.net http://home.comcast.net/~djmpark/ From: Michael Stern [mailto:nycstern at gmail.com] 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