ok, so lists in elixir are linked lists, so the list [1, 2] is actually (1 → (2 → ??))
That ?? has to be something, it can’t be dangling. By convention we pick [], because it makes a lot of recursion type things look really nice, and as a bonus [] at two bytes is the smallest object in the erlang world.
so really it’s (1 → (2 → []))
However, ?? could be literally anything, so if it’s anything besides [], then it’s called an improper list. A lot of things (like the entire Enum module) break with improper lists, and you have to handle recursion with care - so be careful. Why would you use it? It does take slightly less space, so if you are implementing something on a system with tight storage requirements (like embedded) with a ton ton ton of really short lists, it might be worth it.
Also note the notational differences, if you have an improper list (1 → (2 → 3)), the default notate it is:
[1, 2 | 3]
which is not the same as
[1, 2, 3]
which is (1 → (2 → (3 → [])))






















