Given this code:
mylist = Tuples[{a, e}, 2];
Insert[mylist, 1, {#, 3}] & /@ Range[2]
The output is this:
{{{a, a, 1}, {a, e}, {e, a}, {e, e}}, {{a, a}, {a, e, 1}, {e, a}, {e, e}}}
But the desired output is this:
{{a, a, 1}, {a, e,1}, {e, a}, {e, e}}
Apparently mylist is multiplied along the way. How to avoid this?
Insert[mylist, 1, {{1, 3}, {2, 3}}]to get your output, which you could also write asInsert[mylist, 1, {#, 3} & /@ Range[2]]if you want to useRange. – MarcoB Jul 28 '17 at 20:40Inactive[Insert][mylist, 1, {#, 3}] & /@ Range[2], i.e. to see the effect of mapping before the insertion happens. – MarcoB Jul 28 '17 at 20:45