How do I flatten a list of the form
{{{1, 2}, 3}, {{4, 5}, 6}, {{7, 8}, 9},...}
to put it in the form
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9},...}
required to use ListDensityPlot? Thanks in advance for any help.
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityHow do I flatten a list of the form
{{{1, 2}, 3}, {{4, 5}, 6}, {{7, 8}, 9},...}
to put it in the form
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9},...}
required to use ListDensityPlot? Thanks in advance for any help.
Flatten[#] & /@ {{{1, 2}, 3}, {{4, 5}, 6}, {{7, 8}, 9}}
{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
The above Flattens each sublist.
Mr. Hanlon makes the good point that:
Flatten /@ {{{1, 2}, 3}, {{4, 5}, 6}, {{7, 8}, 9}}
works as well.
Flatten /@ list
also works.
$\endgroup$
– Bob Hanlon
Dec 31 '20 at 18:00
Interpolation
andDensityPlot
$\endgroup$ – cvgmt Jan 1 at 1:37ReplaceAll
. Like so:data /. {{a_, b_}, c_} -> {a, b, c}
$\endgroup$ – m_goldberg Jan 1 at 1:59