Interface LList<T>

Type Parameters:
T - type of the list items
All Known Implementing Classes:
LList.ImmutableList, LList.Nil

public sealed interface LList<T> permits LList.Nil<T>, LList.ImmutableList<T>
Defines an immutable list structure as used in Lisp, Scheme, or Clojure. The fundamental data structure in many functional languages is the immutable list. It is constructed from two building blocks:
Nil
The empty list
Cons
A cell containing an element also known as first; and a pointer to the rest of the list also known as tail.

The term cons comes from functional programming language Lisp or Scheme. These kind of data structures are called persistent data structures. Since the data structure is immutable, one might think that a lot of memory would be consumed since a new list would be created when we try to perform various operations on list. On the contrary, these kind of data structures allow structural sharing by sharing nodes. A persistent data structure does preserve the previous version of itself when being modified and is therefore effectively immutable. Fully persistent data structures allow both updates and queries on any version.