# Remove inner brackets

If I have the result

{{Position, {Code}},
{1, {0000, 0001}},
{2, {0100, 0011}},
{3, {0110, 0111}},
{4, {1000, 1001}},
{5, {1100,1011}},
{6, {1110, 1111}}}


and I want it to be

{{Position, Code},
{1, 0000, 0001},
{2, 0100, 0011},
{3, 0110, 0111},
{4, 1000, 1001},
{5, 1100, 1011},
{6, 1110, 1111}}


I tried

//.{x_,{y_}}:> {x,y}


but that seems to work only for the first element.

Any help would be appreciated Thanks.

list // Map[Flatten]


{{Position, Code}, {1, 0, 1}, {2, 100, 11}, {3, 110, 111}, {4, 1000, 1001}, {5, 1100, 1011}, {6, 1110, 1111}}

• That's an original alternative to the – more common, I presume – Flatten /@. – corey979 Oct 20 at 19:50

Try

list={{Position,{Code}},{1,{0000,0001}},{2,{0100,0011}},{3,{0110,0111}},{4,{1000,1001}},{5,{1100,1011}},{6,{1110,1111}}}

list /. {a_ ,  b_List } -> Join[{a}, b]


You were really close. You just need to add another underscore to y_ as

list = {
{Position, {Code}},
{1, {0000, 0001}},
{2, {0100, 0011}},
{3, {0110, 0111}},
{4, {1000, 1001}},
{5, {1100,1011}},
{6, {1110, 1111}}
};

list /. {x_, {y__}} :> {x, y}


{{Position, Code}, {1, 0000, 0001}, {2, 0100, 0011}, {3, 0110, 0111}, {4, 1000, 1001}, {5, 1100, 1011}, {6, 1110, 1111}}

Level[#, {-1}] & /@ list

Apply[Sequence, list, {-2}]

Map[Splice, list, {-2}]

Join[{#}, #2] & @@@ list

Prepend[#2, #]& @@@ list

MapAt[Splice, {All, 2}] @ list

ReplacePart[{_, 2, 0} -> Sequence] @ list

Map[Map @ Apply @ Sequence] @ list

Delete[{2, 0}] /@ list

FlattenAt[#, 2] & /@ list


... and for the Halloween:

☺ = ## & @@@ # & /@ # &;

☺ @ list

{{Position, Code}, {1, 0, 1}, {2, 100, 11}, {3, 110, 111}, {4, 1000, 1001},
{5, 1100, 1011}, {6, 1110, 1111}}


☺☺ = {#, ## & @@ #2} & @@@ # &;

☺☺ @ list

{{Position, Code}, {1, 0, 1}, {2, 100, 11}, {3, 110, 111}, {4, 1000, 1001},
{5, 1100, 1011}, {6, 1110, 1111}}

• A little explanation: ## & @@@ # & nearly == Flatten , a nice trick ;) . So the first 'riddle' == Flatten /@ list. – wuyudi Oct 20 at 12:05
• Showing off, but still a... Wow! – nilo de roock Oct 22 at 9:36

ReplacePart can do it.

data =
{{Position, {Code}},
{1, {0000, 0001}}, {2, {0100, 0011}}, {3, {0110, 0111}},
{4, {1000, 1001}}, {5, {1100, 1011}}, {6, {1110, 1111}}};
ReplacePart[data, {i_, 2} :> Sequence @@ data[[i, 2]]]

{{Position, Code},
{1, 0, 1}, {2, 100, 11}, {3, 110, 111},
{4, 1000, 1001}, {5, 1100, 1011}, {6, 1110, 1111}}