Comment

Peter Bengtsson

Fair point! doing `combined.insert` was meant as an example of mutating the new list. You're right, it doesn't really prove that `winners` and `losers` are immutable. I just wanted to demonstrate that once `combined` has been created, and if you change it, it doesn't change the lists that were used to *create* the new list.

Parent comment

Phil Colbert

Ouch again. Sorry to do this... combined.insert(0, 100) doesn't prove that anything is *im*mutable. Rather, it proves that "combined" is mutable. Is your goal is to prove that subsequences "winners" and "losers" are not shared with "combined"? If so, then you need a different proof, e.g., alter a position in "combined" that "would" be shared.

Replies

Phil Colbert

Yes. Alas, the term for that is not "immutable". "immutable" is an adjective, and applies to data structures, such as a tuple or frozenset. It is not an adverb, so it does not apply to actions, such as operators, or function calls. On a constructive note, perhaps the phrase you're looking for is "side-effect free".

As for the number of lists... You demonstrate that, after the concatenation, you really do have *three* lists, not one. I'm at a loss as to how to fix the title to reflect that.