# Put list in a special format

I am having problems with a list that I want to put in a special format and I would like you to help me, the list I have is the following:

dts={{Polygon[{{11/2, 0}, {37/8, 5/8}, {29/8, -(5/8)}}],
1, {11/2, 0}}, {Polygon[{{37/8, 5/8}, {15/4, 5/4}, {29/8, -(5/8)}}],
2, {37/8, 5/
8}}, {Polygon[{{29/8, -(5/8)}, {7/2, -(5/2)}, {9/2, -(5/4)}}],
3, {29/8, -(5/
8)}}, {Polygon[{{9/2, -(5/4)}, {11/2, 0}, {29/8, -(5/8)}}],
4, {9/2, -(5/4)}}, {Polygon[{{11/2, 0}, {13/2, 5/4}, {45/8, 15/8}}],
5, {11/2, 0}}, {Polygon[{{13/2, 5/4}, {15/2, 5/2}, {45/8, 15/8}}],
6, {13/2, 5/4}}, {Polygon[{{45/8, 15/8}, {15/4, 5/4}, {37/8, 5/8}}],
7, {45/8, 15/8}}, {Polygon[{{37/8, 5/8}, {11/2, 0}, {45/8, 15/8}}],
8, {37/8, 5/8}}, {Polygon[{{7/4, -(5/4)}, {11/4, 0}, {15/8, 5/8}}],
9, {7/4, -(5/4)}}, {Polygon[{{11/4, 0}, {15/4, 5/4}, {15/8, 5/8}}],
10, {11/4, 0}}, {Polygon[{{15/8, 5/8}, {0, 0}, {7/8, -(5/8)}}],
11, {15/8, 5/
8}}, {Polygon[{{7/8, -(5/8)}, {7/4, -(5/4)}, {15/8, 5/8}}],
12, {7/8, -(5/
8)}}, {Polygon[{{7/4, -(5/4)}, {21/8, -(15/8)}, {29/8, -(5/8)}}],
13, {7/4, -(5/
4)}}, {Polygon[{{21/8, -(15/8)}, {7/2, -(5/2)}, {29/8, -(5/8)}}],
14, {21/8, -(15/
8)}}, {Polygon[{{29/8, -(5/8)}, {15/4, 5/4}, {11/4, 0}}],
15, {29/8, -(5/
8)}}, {Polygon[{{11/4, 0}, {7/4, -(5/4)}, {29/8, -(5/8)}}],
16, {11/4,
0}}, {Polygon[{{21/4, -(15/4)}, {25/4, -(5/2)}, {43/8, -(15/8)}}],
17, {21/4, -(15/
4)}}, {Polygon[{{25/4, -(5/2)}, {29/4, -(5/4)}, {43/8, -(15/8)}}],
18, {25/4, -(5/
2)}}, {Polygon[{{43/8, -(15/8)}, {7/2, -(5/2)}, {35/8, -(25/8)}}],
19, {43/8, -(15/
8)}}, {Polygon[{{35/8, -(25/8)}, {21/4, -(15/4)}, {43/
8, -(15/8)}}],
20, {35/8, -(25/
8)}}, {Polygon[{{21/4, -(15/4)}, {49/8, -(35/8)}, {57/
8, -(25/8)}}],
21, {21/4, -(15/
4)}}, {Polygon[{{49/8, -(35/8)}, {7, -5}, {57/8, -(25/8)}}],
22, {49/8, -(35/
8)}}, {Polygon[{{57/8, -(25/8)}, {29/4, -(5/4)}, {25/4, -(5/2)}}],
23, {57/8, -(25/
8)}}, {Polygon[{{25/4, -(5/2)}, {21/4, -(15/4)}, {57/
8, -(25/8)}}],
24, {25/4, -(5/
2)}}, {Polygon[{{11/2, 0}, {51/8, -(5/8)}, {59/8, 5/8}}],
25, {11/2,
0}}, {Polygon[{{51/8, -(5/8)}, {29/4, -(5/4)}, {59/8, 5/8}}],
26, {51/8, -(5/
8)}}, {Polygon[{{59/8, 5/8}, {15/2, 5/2}, {13/2, 5/4}}],
27, {59/8, 5/8}}, {Polygon[{{13/2, 5/4}, {11/2, 0}, {59/8, 5/8}}],
28, {13/2, 5/
4}}, {Polygon[{{11/2, 0}, {9/2, -(5/4)}, {43/8, -(15/8)}}],
29, {11/2,
0}}, {Polygon[{{9/2, -(5/4)}, {7/2, -(5/2)}, {43/8, -(15/8)}}],
30, {9/2, -(5/
4)}}, {Polygon[{{43/8, -(15/8)}, {29/4, -(5/4)}, {51/8, -(5/8)}}],
31, {43/8, -(15/
8)}}, {Polygon[{{51/8, -(5/8)}, {11/2, 0}, {43/8, -(15/8)}}],
32, {51/8, -(5/
8)}}, {Polygon[{{23/4, 15/4}, {27/4, 5}, {47/8, 45/8}}],
33, {23/4, 15/
4}}, {Polygon[{{27/4, 5}, {31/4, 25/4}, {47/8, 45/8}}],
34, {27/4, 5}}, {Polygon[{{47/8, 45/8}, {4, 5}, {39/8, 35/8}}],
35, {47/8, 45/
8}}, {Polygon[{{39/8, 35/8}, {23/4, 15/4}, {47/8, 45/8}}],
36, {39/8, 35/
8}}, {Polygon[{{23/4, 15/4}, {53/8, 25/8}, {61/8, 35/8}}],
37, {23/4, 15/
4}}, {Polygon[{{53/8, 25/8}, {15/2, 5/2}, {61/8, 35/8}}],
38, {53/8, 25/
8}}, {Polygon[{{61/8, 35/8}, {31/4, 25/4}, {27/4, 5}}],
39, {61/8, 35/
8}}, {Polygon[{{27/4, 5}, {23/4, 15/4}, {61/8, 35/8}}],
40, {27/4, 5}}, {Polygon[{{6, 15/2}, {55/8, 55/8}, {63/8, 65/8}}],
41, {6, 15/
2}}, {Polygon[{{55/8, 55/8}, {31/4, 25/4}, {63/8, 65/8}}],
42, {55/8, 55/8}}, {Polygon[{{63/8, 65/8}, {8, 10}, {7, 35/4}}],
43, {63/8, 65/8}}, {Polygon[{{7, 35/4}, {6, 15/2}, {63/8, 65/8}}],
44, {7, 35/4}}, {Polygon[{{6, 15/2}, {5, 25/4}, {47/8, 45/8}}],
45, {6, 15/2}}, {Polygon[{{5, 25/4}, {4, 5}, {47/8, 45/8}}],
46, {5, 25/
4}}, {Polygon[{{47/8, 45/8}, {31/4, 25/4}, {55/8, 55/8}}],
47, {47/8, 45/
8}}, {Polygon[{{55/8, 55/8}, {6, 15/2}, {47/8, 45/8}}],
48, {55/8, 55/8}}, {Polygon[{{2, 5/2}, {23/8, 15/8}, {31/8, 25/8}}],
49, {2, 5/2}}, {Polygon[{{23/8, 15/8}, {15/4, 5/4}, {31/8, 25/8}}],
50, {23/8, 15/8}}, {Polygon[{{31/8, 25/8}, {4, 5}, {3, 15/4}}],
51, {31/8, 25/8}}, {Polygon[{{3, 15/4}, {2, 5/2}, {31/8, 25/8}}],
52, {3, 15/4}}, {Polygon[{{2, 5/2}, {1, 5/4}, {15/8, 5/8}}],
53, {2, 5/2}}, {Polygon[{{1, 5/4}, {0, 0}, {15/8, 5/8}}],
54, {1, 5/4}}, {Polygon[{{15/8, 5/8}, {15/4, 5/4}, {23/8, 15/8}}],
55, {15/8, 5/8}}, {Polygon[{{23/8, 15/8}, {2, 5/2}, {15/8, 5/8}}],
56, {23/8, 15/
8}}, {Polygon[{{23/4, 15/4}, {19/4, 5/2}, {45/8, 15/8}}],
57, {23/4, 15/
4}}, {Polygon[{{19/4, 5/2}, {15/4, 5/4}, {45/8, 15/8}}],
58, {19/4, 5/
2}}, {Polygon[{{45/8, 15/8}, {15/2, 5/2}, {53/8, 25/8}}],
59, {45/8, 15/
8}}, {Polygon[{{53/8, 25/8}, {23/4, 15/4}, {45/8, 15/8}}],
60, {53/8, 25/
8}}, {Polygon[{{23/4, 15/4}, {39/8, 35/8}, {31/8, 25/8}}],
61, {23/4, 15/4}}, {Polygon[{{39/8, 35/8}, {4, 5}, {31/8, 25/8}}],
62, {39/8, 35/
8}}, {Polygon[{{31/8, 25/8}, {15/4, 5/4}, {19/4, 5/2}}],
63, {31/8, 25/
8}}, {Polygon[{{19/4, 5/2}, {23/4, 15/4}, {31/8, 25/8}}],
64, {19/4, 5/2}}};


and I want it this way:

dts={{Polygon[{{11/2, 0}, {37/8, 5/8}, {29/8, -(5/8)}}],
Text[1, {11/2, 0}]}, {Polygon[{{37/8, 5/8}, {15/4, 5/4}, {29/8, -(5/8)}}],
Text[ 2, {37/8, 5/
8}]}, {Polygon[{{29/8, -(5/8)}, {7/2, -(5/2)}, {9/2, -(5/4)}}],
Text[3, {29/8, -(5/
8)}]},...{Polygon[{{19/4, 5/2}, {23/4, 15/4}, {31/8, 25/8}}],
Text[64, {19/4, 5/2}]}};


I tried with Apply, Map and finally with MapAt without success,I thought I would use Inner and Outer but I did not get the expected result, it is for this reason that I ask for your help in order to solve my problem, this was my last attempt using MapAt and see what I got

MapAt[Text, #, {{2}, {3}}] & /@ dts


as you will see is not how I need it, I hope you can help me. I do not know which command to use here, thanks in advance.

• A slight variation on other answers: dts /. {x_, y_, z_} :> {x, Text[y, z]} Mar 12, 2017 at 7:12

dts2 = {#, Text[##2]} & @@@ dts;

Short[dts2, 3]


• Your solution is how I try to solve it without success, thank you for showing me how to do it, it's what I was looking for, thank you for helping me Mar 12, 2017 at 14:20
• @user1935664, glad to be of help. Thank you for the accept.
– kglr
Mar 12, 2017 at 14:29

Let

dts = {{Polygon[{{11/2, 0}, {37/8, 5/8}, {29/8, -(5/8)}}], 1, {11/2, 0}},
{Polygon[{{37/8, 5/8}, {15/4, 5/4}, {29/8, -(5/8)}}], 2, {37/8, 5/8}}};


then

Cases[dts, {Polygon[x_], y_, z_} :> {Polygon[x], Text[y, z]}]


{{Polygon[{{11/2, 0}, {37/8, 5/8}, {29/8, -(5/8)}}], Text[1, {11/2, 0}]}, {Polygon[{{37/8, 5/8}, {15/4, 5/4}, {29/8, -(5/8)}}], Text[2, {37/8, 5/8}]}}

And for completeness, to take into account the comment of tomd above:

dts /. {x_, y_, z_} :> {x, Text[y, z]}

• Thanks a lot for your help, I learned more about using the Cases command, this command had not taken into account. Mar 12, 2017 at 14:17