# Add Brackets to a string list

Hello stackexchange community!

I have a stringlist with a value and his error for eg:

{{"12","1"},{"13","2"}}


Now i want to output this as something like this (for a lab-report):

{"12(1)","13(2)"}


Unfortunately I have no idea how to get this working...

Cx

-
Your first list as pasted does not contain strings, but integers. Could you clarify? – Yves Klett Nov 11 '13 at 13:09
sorry, i corrected the error now – cxkoda Nov 11 '13 at 13:21
now I solved it like this: errformat[list_] := Table[StringJoin[ToString[list[[i, 1]]], "(", ToString[list[[i, 2]]], ")"], {i, 1, Dimensions[list][[1]]}] – cxkoda Nov 11 '13 at 13:32
thanks for your tipps – cxkoda Nov 11 '13 at 13:33
I would recommend Chris solution, which is clean&instructive. BTW, try Length[list]. – Yves Klett Nov 11 '13 at 13:35

Or with a pattern:

{{"12", "1"}, {"13", "2"}} /. {a_String, b_String} :> StringJoin[a, "(", b, ")"]

-

Using Apply:

StringJoin[#1, "(", #2, ")"] & @@@ {{"12", "1"}, {"13", "2"}}


{"12(1)", "13(2)"}

-
Cleaner than mine :-) – Yves Klett Nov 11 '13 at 13:34

Depending on what you intend to do with the output you may also use StringForm:

StringForm["()", ##] & @@@ {{"12", "1"}, {"13", "2"}}


{12(1),13(2)}

Internally this remains as a StringForm expression which may be good or bad given the circumstance.

-

ToString[#[[1]]] <> "(" <> ToString[#[[2]]] <> ")" & /@ {{12,1}, {13, 2}}


{"12(1)", "13(2)"}

Edit: with all elements as strings, you can dump ToString:

#[[1]] <> "(" <> #[[2]] <> ")" & /@ {{"12", "1"}, {"13", "2"}}
`
-