Design patterns·Functional ideas that went mainstream
you added an item and got a new list back, and the old one is still there and still valid.
Persistent data structure
Also calledimmutable collection, functional data structure
A structure that preserves its previous versions when modified, so every update yields a new value and the old one remains usable. The naive implementation copies everything and is unusable at scale; real ones share the unchanged parts, which is what makes immutability affordable. It is what underpins undo stacks, time-travel debugging and the change detection in several frontend frameworks.