I have a list:
mainlist={0.23, 0.34, 0.8, 0.0, -0.2, 0.4, -0.1};
I have to extend the above list to another one finalresult with Length=17. But in finalresult the elements of the mainlist must be in the positions ruled by the positionlist:
positionlist={3,4,8,9,10,13,14};
finalresult={0,0,0.23,0.34,0,0,0,0.8,0.0,-0.2,0,0,0.4,-0.1,0,0,0}
How can I reach this goal? I would be so glad to see an answer.
finalresult = ConstantArray[0, 17]; finalresult[[positionlist]]=mainlistin the meantime. – Carl Woll Aug 26 '17 at 14:23