liveBook · Manning

Tail

As explained in Elixir in Action, Third Edition

The tail of a list is the remainder following its first element in a head-and-tail representation.

A tail is the remainder of a list after its first element, exposed by decomposing a list into a head and tail. Because lists are singly linked, this structure supports traversal rather than direct positional access. section 2.4.4

Extracting the tail

For [1, 2, 3, 4], hd/1 returns 1 and tl/1 returns [2, 3, 4]. The same structure can be written as [head | tail]. section 2.4.4

iex(1)> prime_numbers = [2, 3, 5, 7]
[2, 3, 5, 7]

Use the linked examples to inspect list construction and tail extraction interactively. section 2.4.4

How Elixir in Action, Third Edition covers it

How deep it goes
Explains recursive structure and extraction with tl/1, but defers recursive algorithms and detailed complexity analysis.
Examples
Demonstrates [1, 2, 3, 4], [head | tail], and tl([1, 2, 3, 4]).
What it assumes
Builds the list model from recursive construction and distinguishes lists from arrays and direct-access structures.
What you can do after
Apply tl/1 to obtain the remainder of a nonempty list and recognize its head-and-tail form.
How it connects
Connects tails with lists, singly linked lists, heads, and list traversal.

Also explained in

Compare how 3 books explain tail →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Elixir in Action, Third Edition. The section links point to the parts of the book it draws on.