Multiple inserts can be made using FoldFold
or ReplaceAll
, e.g.
list = {1, 2, 3, 4, 5, 6, 7, 8, 9};
Fold[Insert[#1, #2[[1]]First[#2], #2[[2]]]Last[#2]] &, list, {{"a", 2}, {"b", 4}, {"c", 6}}]
{1, a, 2, b, 3, c, 4, 5, 6, 7, 8, 9}
list /. {x_Integer, y_, z_, rest__} :> {x, "a", y, "b", z, "c", rest}
{1, "NovNov 9 2017 13:24"24, "Thursday"Thursday, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
Resetting allEntries
for the multiple insertFold
method.
{1, "NovNov 9 2017 13:24"24, "Thursday"Thursday, "Friday"Friday, "Saturday"Saturday, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}
Much easier to use Easier usingReplaceAll
.
{1, "NovNov 9 2017 13:24"24, "Thursday"Thursday, "Friday"Friday, "Saturday"Saturday, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15}