Search⌘ K

Immutable lists

Explore immutable lists as persistent data structures in PHP that always return updated versions without modifying previous ones. Learn to use PHP libraries like immutable-php and phunkie for creating and manipulating immutable lists. Understand their benefits, implementations using SPL fixed arrays, and practical transformations like filtering and tokenization.

What are immutable lists?

An immutable list is a persistent data structure. That is, it’s a data structure that maintains its previous version whenever it’s modified. An immutable list always yields an updated version of itself. It’s possible to view an immutable list as an upgrade of constants, which don’t have the properties of persistent structures.

PHP libraries supporting immutable lists

There exists multiple libraries in PHP capable of enabling the creation of immutable lists. Among the packages with ...