# How to get a list of pairs into the form $(x,y)$?

I want to put the solutions of the equation $y = (x + 3)/(x - 3)$, where $x$, $y$ are integers, into the form $(x,y)$. For example, $(2, -5)$ instead of $\{2,-5\}$. When I evaluated

{x, y} /. Solve[y == (x + 3)/(x - 3), {x, y}, Integers]


I got

{{-3, 0}, {0, -1}, {1, -2}, {2, -5}, {4, 7}, {5, 4}, {6, 3}, {9, 2}}


How do I get $(-3,0),\,(0,-1),\,\ldots$?

-
Can you please explain why you'd want that? Is it purely to display the list "nicely"? – Pinguin Dirk Oct 3 '13 at 8:11
In my country, the pair of solution must be formated like that. After Mathematica out put, I use TeXform to convert them. – minthao_2011 Oct 3 '13 at 8:50

I assume you know (1,2) will result in an error while interpreting by FE and that form you need is for output/presentation purposes:

StringForm["(,)", ##] & @@@ {{-3, 0}, {0, -1}, {1, -2}, {2, -5}, {4, 7}, {5, 4},
{6, 3}, {9, 2}}


{(-3,0),(0,-1),(1,-2),(2,-5),(4,7),(5,4),(6,3),(9,2)}

-
StringReplace[#, {"{" -> "(",
"}" -> ")"}] & /@ (ToString /@ {{-3,
0}, {0, -1}, {1, -2}, {2, -5}, {4, 7}, {5, 4}, {6, 3}, {9, 2}})

-
+1, notice that StringReplace automatically threads over list so you do not have to Map with it. – Kuba Oct 3 '13 at 12:25
@Kuba thank you, should have known but always nice to learn – ubpdqn Oct 3 '13 at 12:27

You could use Row to predefine output format and again to display it as you want with ", " as the separator between Row elements

Row[Row@{"(", x, ", ", y, ")"} /.Solve[y == (x + 3)/(x - 3), {x, y}, Integers], ", "]

(-3, 0), (0, -1), (1, -2), (2, -5), (4, 7), (5, 4), (6, 3), (9, 2)

-

You may only obtain it if you agree to have the strings of the desired form, since otherwise the "(" and ")" parentheses are reserved for a different purpose. Try this:

This is your list of solutions

 lst = {x, y} /. Solve[y == (x + 3)/(x - 3), {x, y}, Integers]


(*
{{-3, 0}, {0, -1}, {1, -2}, {2, -5}, {4, 7}, {5, 4}, {6, 3}, {9, 2}} *)

and this makes the string of solution:

Map["(" <> ToString[#[[1]]] <> "," <> ToString[#[[2]]] <> ")" &, lst]

{"(-3,0)", "(0,-1)", "(1,-2)", "(2,-5)", "(4,7)", "(5,4)", "(6,3)", \
"(9,2)"}

-