user=> (let [x [3 2 1]] (sort x) x)
[1 2 3]
The sort function mutates the vector. This can happen because the
toArray() method of LazilyPersistenVector returns its own internal
array, instead of creating a new array like most other collections do.
sort then passes this along to Java's Arrays.sort() which mutates the
array.
Attached is a patch that makes LPV toArray() return a clone of the
array. This is of course somewhat less efficient, but it seems like
any less drastic solution leaves open the possibility of mutating the
array inside the vector.
--Chouser