I am trying to add an element to a nested list. An example of the nested list is given below:
cordxy = {{{1, 2}, {3, 4}, {5, 6}}, {{7, 8}, {9, 10}, {1, 2}}}
I would like to add an element to the elements of the list without changing the structure of the list. Basically, the result I want is (assuming the extra element is a):
{{{1, 2, a}, {3, 4, a}, {5, 6, a}}, {{7, 8, a}, {9, 10, a}, {1, 2, a}}}
I have found a way of doing so by mapping a Map
function (or Nest
-ing a Map
):
Map[Map[Insert[#, a, {3}] &, #] &, cordxy]
I would like to know if there is better way of doing it.
Thanks in advance, Drod