1
$\begingroup$

I have an obviously easy task, but I can't do it, and I could not find a solution by searching the site.

I have a list as follows:

lis1 = {{{1, 2, 3}, {3, 4, 7}}, {{6, 7, 8}, {4, 2, 2}}}

and would like to flatten it to

lis = {{1, 2, 3, 3, 4, 7}, {6, 7, 8, 4, 2, 2}}

Does anyone have a hint?

$\endgroup$

closed as off-topic by C. E., bbgodfrey, Bob Hanlon, 2012rcampion, xyz Apr 30 '15 at 2:30

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – C. E., bbgodfrey, Bob Hanlon, 2012rcampion, xyz
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 4
    $\begingroup$ You need to put the right hand side of your first line inside braces (as is it is not a valid expression). Then you can use Join@@@lis1 or Map[Flatten, lis1, 1] or Flatten/@lis1 etc. $\endgroup$ – kglr Apr 29 '15 at 23:32
4
$\begingroup$

Presuming that your data really is given by

data = {{{1, 2, 3}, {3, 4, 7}}, {{6, 7, 8}, {4, 2, 2}}};

then I would use Join and Apply (at level 1),

Join @@@ data
{{1, 2, 3, 3, 4, 7}, {6, 7, 8, 4, 2, 2}}
$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.