Inserting some zeros in a list by a rule of positions

Normal@SparseArray[Thread[positionlist -> mainlist], 17, 0]

Update: should emphasize C.E.'s nice comment:

Normal@SparseArray[positionlist -> mainlist, 17]

equivalent in result, more pleasantly laconic, and lack of explicit thread actually less expensive for longer lists.


mainlist={0.23, 0.34, 0.8, 0.0, -0.2, 0.4, -0.1};
positionlist={3,4,8,9,10,13,14};

ReplacePart[ConstantArray[0, 17], Thread[positionlist -> mainlist]]

or what @Carl Woll suggested:

finalresult = ConstantArray[0, 17];
finalresult[[positionlist]] = mainlist