There is no built-in function or a method of a List that would allow user to add a new element in a certain position of a List. I\'ve wrote a function that does this but I\'
You can also use xs.patch(i, ys, r), which replaces r elements of xs starting with i by the patch ys, by using r=0 and by making ys a singleton:
xs.patch(i, ys, r)
r
xs
i
ys
r=0
List(1, 2, 3, 5).patch(3, List(4), 0)