Interior mutablility:
A, immutable, points to B.
B, immutable, points to C.
C, mutable, points to D.
D, immutable, points to E.
Even though A and B are immutable -- B points to C mutably, so you can modify its contents. Some "interior" part of A (and of B) is mutable. You can't change which C is pointed to by B (because B is immutable, or rather we only have an immutable reference to it), but it's open season on the contents of C.
What this article describes:
We have 2 operations.
We are passed in Array A.
We can either:
- Apply both operations to A, modifying it even though the "owner" may not want this.
- Copy before each operation (or as part of them), which leaves A untouched, but requires triple the memory usage.
- Cooy before (or as part of) the first operation only. The second operation can be applied in-place on the copy. This leaves A untouched and only requires double the memory.
They're totally different concepts. I don't know what you'd call the second concept -- I think the important part is that A remains untouched, so... "Avoiding side effects while reducing memory usage", or "How to make performant pure functions" ?