Immutable vectors / lists usually provide quick updates, allowing only inserts from one end and then sharing immutable data at the other end. If you want to do non-main / tail inserts, what you really want to do is change the immutable end of your collection. You will need to divide the vector around the element that you want to insert, and then combine it again to create a new vector, and best of all you can do it - this is O (n) time.
Immutable sorted trees work a little differently, but they won't let you re-specify characters (keys) in less than O (n) time.
In principle, if someone has discovered an effective way to support random access inserts in an immutable vector, then it will be supported in one of the main functional languages ββ- but there is no such known data structure or algorithm, so there are no such implementations.
source share