# Appending/Prepending a vector to a TableForm

How do i Append(Prepend) to a List?

A = {{a,b},{c,d}} // TableForm
B = {x, y}
MapThread[Prepend, {A,B}]


does not work. If i leave out the TableForm it does. This could be solved by converting TableForm of a List back to a list which works:

A = {{a,b},{c,d}}
B = {x, y}
MapThread[Prepend, {A,B}]


But how do i do such if A allready is in TableForm? Should i generally allways avoid outputting as TableForm if the structure contains data?

## 3 Answers

MapAt[MapThread[Prepend, {#, B}] &, A, {1}] I just found a solution myself:

AList = A[]


and hence

A = {{a,b},{c,d}} // TableForm
B = {x, y}
MapThread[Prepend, {A[],B}] // TableForm


since ListForm is just a Head. This way most heads can be detached.

• What I usually do in my code is add parentheses, "( A = {{a,b},{c,d}} ) // TableForm" so it keeps lists as lists, but I can see it in TableForm, or MatrixForm, or whatever. – MikeY Dec 13 '18 at 16:07

First of all you should define A without //TableForm

A = {{a,b},{c,d}}
B = {x, y}
Transpose[Join[{B},A]] (* or Thread[Join[{B}, A ]]*)
(*{{x, a, c}, {y, b, d}}*)

• This circumvention of the issue was allready mentioned in the question. I looked for a solution which does this on TableForms etc. I was able to solve it myself after having posted the question hence i answered myself. – Gladaed Dec 13 '18 at 16:46
• Sorry for trying to give you a helpful answer. – Ulrich Neumann Dec 13 '18 at 16:51
• @Gladaed You are going to make yourself very unhappy by sticking to wrapping things into TableForm. – Henrik Schumacher Dec 13 '18 at 17:39