Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'flattenAt applied to {All} instead of by intege...' topicStudent Support Forum > General > Archives > "flattenAt applied to {All} instead of by intege..."

Next Comment >Help | Reply To Topic
Author Comment/Response
curiousgeorge
01/24/12 10:41am

I've got an array which has a level that is nested within another. I'd like to flatten this specific level out, but I can't figure out how...

in short, I want to flatten an array from DIMENSIONS of {3,2,3,1,4} to {3,2,3,4} and I can't figure out how.

here's an example:

tmp = {{a, {b, c}, {{d, e}}}, {a, {b, c}, {{d, e}}}};
FlattenAt[tmp, {{1, 3}, {2, 3}}] yields {{a, {b, c}, {d, e}}, {a, {b, c}, {d, e}}}.

However, in order for this to work, I have to specifify each index pair in the 'flattenAt' command. This isn't a problem for small arrays, but when I have something with dimensions of {3,2,3,1,4}, it starts to become difficult. there has to be a better way to do this

thanks
cg

URL: ,

Subject (listing for 'flattenAt applied to {All} instead of by intege...')
Author Date Posted
flattenAt applied to {All} instead of by intege... curiousgeorge 01/24/12 10:41am
Re: flattenAt applied to {All} instead of by in... curiousgeorge 01/24/12 10:57am
Next Comment >Help | Reply To Topic