I have an initial list:
list0 = {1,2,3,4,5};
and I want to insert {a,x} at specific positions {1,5}, which means that I want the resulting list to have a at position 1 and x at position 5. This is different from what Mathematica's Insert does, and what has been asked here before (Looking for a way to insert multiple elements into multiple positions simultaneously in a list). In my example, the output I expect is:
In[]: myInsert[list0, {a,x}, {1,5}]
Out[]: {a,1,2,3,x,4,5}
What's a clean way to do this? And what's a good name for this type of insertion?
Multidimensional version: Insert at specific resulting positions in multidimensional list?
myInsert[list0,{a,x},{4,1}],{x,1,2,a,3,4,5}or{x,1,2,3,a,4,5}? – andre314 Dec 04 '14 at 17:03myInsert[list0,{a,x},{4,1}]should output{x,1,2,a,3,4,5}. The list of positions{4,1}gives the positions of the inserted elements in the resulting list. – a06e Dec 04 '14 at 17:05