# How to substitute curly brackets with round brackets in a grid of list

I want to produce a table (or a grid) from my list of data, as follows:

eq01={0.01,1.02};
ev01={{1,3},{2,4}};
ev02={{5,5},{6,1}};
data1 = {{"", "Equilibrium points", "Eigenvalues",
"Eigenvectors"}, {"A = 0",eq01,ev01,ev02}};

Grid[data1, Alignment -> Left, Spacings -> {2, 1}, Frame -> All,
ItemStyle -> "Text"]


And what I obtain is the following: Is there a way to: 1) flatten the lists under "Eigenvalues" and "Eigenvectors" without using flatten for every definition of list in the beginning? Because I have many eigenvalues and eigenvectors and it would be very long; 2) substitute the curly brackets with round brackets, to have for example, in the second column and second row, (0.01,1.02)?

I hope the question is clear, thanks in advance!

Edit
also for many rows

eq01={0.01,1.02};
ev01={{1,3},{2,4}};
ev02={{5,5},{6,1}};
data1=StringReplace[#,{"{{"->"(","}}"->")","{"->"(","}"->")"}]&/@
ToString/@#&/@{{"","Equilibrium points","Eigenvalues","Eigenvectors"},{"A = 0",eq01,ev01,ev02}};

Grid[data1,Alignment->Left,Spacings->{2,1},Frame->All,ItemStyle->"Text"] • Almost, actually I did not mention clearly that in the eigenvalues and eigenvectors columns I would like to have: (1,3),(2,4) and (5,5),(6,1), so I would need to keep the internal brackets and substitute them with round brackets. Do you know how I could do? And is there a way to write the rule only once for the entire data (which is longer than just this one in reality) and not for every row? Thanks! Apr 12 '19 at 13:02
• Esperanta, you said "flatten the lists under "Eigenvalues" and "Eigenvectors"... but now you are changing both of your questions... let me see what I can do. You should also try yourself now that I showed you the basics ;-) Apr 12 '19 at 13:10
• @Esperanta I updated the answer. Please check it Apr 12 '19 at 13:29

I think you have to use a custom formatting utility of some sort:

vectorForm[v_?VectorQ] := Row[{"(", Row[v, ","], ")"}];

Grid[data1 /. {
m_?(MatrixQ[#, NumericQ] &) :> Row[vectorForm /@ m, ","],
v_?(VectorQ[#, NumericQ] &) :> vectorForm[v]},
Alignment -> Left, Spacings -> {2, 1}, Frame -> All,
ItemStyle -> "Text"] One distinct advantage of this approach is that it leverages Mathematica's expression formatting capabilities and avoids the lack of robustness of ToString[]. Compare the above method with @J42161217's on normalized eigenvectors:

eq01 = {0.01, 1.02};
ev01 = {{1, 3}, {2, 4}};
ev02 = Normalize /@ {{5, 5}, {6, 1}};

(* @MichaelE2 *)
data2 = {{"", "Equilibrium points", "Eigenvalues",
"Eigenvectors"}, {"A = 0", eq01, ev01, ev02}};
Grid[data2 /. {
m_?(MatrixQ[#, NumericQ] &) :> Row[vectorForm /@ m, ","],
v_?(VectorQ[#, NumericQ] &) :> vectorForm[v]},
Alignment -> Left, Spacings -> {2, 1}, Frame -> All,
ItemStyle -> "Text"] (* @J42161217 *)
data2 = StringReplace[#, {"{{" -> "(", "}}" -> ")", "{" -> "(",
"}" -> ")"}] & /@ ToString /@ # & /@ {{"",
"Equilibrium points", "Eigenvalues", "Eigenvectors"}, {"A = 0",
eq01, ev01, ev02}};
Grid[data2, Alignment -> Left, Spacings -> {2, 1}, Frame -> All,
ItemStyle -> "Text"] Something similar happens with ordinary fractions and square roots.

Original formatting, in which a set appears in set notation:

Grid[data1 /. v_?(VectorQ[#, NumericQ] &) :> vectorForm[v],
Alignment -> Left, Spacings -> {2, 1}, Frame -> All,
ItemStyle -> "Text"] • I think in order to get what OP asks you should replace "{("->"(" Apr 12 '19 at 13:14
• @J42161217 Maybe so. I'm not sure, but the OP will clarify, I suppose. Apr 12 '19 at 13:20
• OP clarified in the comments of my answer. I think you should check it Apr 12 '19 at 13:31
• @J42161217 I had read that. I'm still not sure, since the OP did not say that the outer braces were unwanted. For all I know it's only the interior formatting that matters. Currently my answer shows the set of eigenvectors in standard notation, which may or may not be a more desirable format. It's easy to change. As I said, you may be right, but it's the OP I want to hear from before I change the answer. Apr 12 '19 at 13:37
• Yes actually I needed to keep only the internal brackets and make them round. The answer by J42161217 is what I was looking for. Thanks! Apr 12 '19 at 14:37

Another possibility is to define a form that automatically formats numeric vectors and numeric matrices as desired:

MakeBoxes[EigenForm[e_], StandardForm] ^:= InternalInheritedBlock[
{MakeBoxes},
MakeBoxes[m_List?numericVectorQ, StandardForm] := RowBox[
{"(", MakeBoxes[Row[m, ","], StandardForm], ")"}
];
MakeBoxes[m_List?numericMatrixQ, StandardForm] := RowBox[
BoxFormAddCommas @ BoxFormListMakeBoxes[m, StandardForm]
];
MakeBoxes[e, StandardForm]
]

SetAttributes[{numericMatrixQ, numericVectorQ}, HoldAll];

numericMatrixQ[e_]:=MatrixQ[Unevaluated[e], SystemDumpHeldNumericQ]
numericVectorQ[e_]:=VectorQ[Unevaluated[e], SystemDumpHeldNumericQ]


Michael's example:

eq01 = {0.01,1.02};
ev01 = {{1,3},{2,4}};
ev02 = Normalize/@{{5,5},{6,1}};

data2={{"","Equilibrium points","Eigenvalues","Eigenvectors"},{"A = 0",eq01,ev01,ev02}};
Grid[
data2,
Alignment -> Left, Spacings -> {2, 1}, Frame -> All, ItemStyle -> "Text"
] //EigenForm
` 