How do you replace an element by index with an immutable List.
E.g.
val list = 1 :: 2 ::3 :: 4 :: List() list.replace(2, 5)
You can use list.updated(2,5) (which is a method on Seq).
list.updated(2,5)
Seq
It's probably better to use a scala.collection.immutable.Vector for this purpose, becuase updates on Vector take (I think) constant time.
scala.collection.immutable.Vector
Vector