6

I have a list that looks like:

z={{{a,b},{b,c},{c,d},{d,e}},{{b,c},{d,e},{w,e}}}

How would I create a list that looks like:

zz={{a,b,b,c,c,d,d,e},{b,c,d,e,w,e}}

I have tried Flatten but that doesn't seem to work at the desired level.

D'Angelo
  • 473
  • 2
  • 5

2 Answers2

10

You can tell Flatten to leave level 1 as-is but to flatten levels 2 and 3 together:

Flatten[z, {{1}, {2, 3}}]
(* {{a, b, b, c, c, d, d, e}, {b, c, d, e, w, e}} *)

This syntax is quite flexible, see Flatten command: matrix as second argument.

WReach
  • 68,832
  • 4
  • 164
  • 269
8

Try the map function

list = {{{a, b}, {b, c}, {c, d}, {d, e}}, {{b, c}, {d, e}, {w, e}}}
Flatten /@ list
5000101
  • 111
  • 3