Study resource
Lists in functional programming study guide
Study Lists in functional programming with curriculum-aligned Study Guide resources, practice links, and exam-focused support.
At a glance
study guide
Resource type
Topic
Lists in functional programming
Study guide overview
Deeper Study Guide: Applying Head-and-Tail List Reasoning
Use the head-and-tail model to trace list operations, explain the type of each result, and check the difference between empty lists, single-element lists and longer lists.
Build the model first
When given a list, identify its head and tail before selecting an operation. For
[4, 3, 5], the head is4and the tail is[3, 5]. Applying the same description to the tail gives a new head of3and a new tail of[5]. The tail remains a list at every stage. Eventually, the tail can be[], which shows that a list may be empty.Trace operations carefully
Suppose
values = [4, 3, 5].- Returning the head produces the element
4. - Returning the tail produces the list
[3, 5]. - Testing whether
valuesis empty produces false, because it contains elements. - Returning its length produces
3. - Prepending
2produces[2, 4, 3, 5]; the new item becomes the head. - Appending
2produces[4, 3, 5, 2]; the existing head remains4.
These results should be described precisely. A head operation returns an element, while a tail operation returns a list. Length returns a number, and an empty-list test returns a decision about whether the list contains no elements.
Boundary cases
Check
[]separately. It is a valid list, but it has no head and no tail. Its length is0, and an empty-list test should identify it as empty. A single-element list such as[7]has head7and tail[]. This is a useful test because it demonstrates that the tail can become the empty list even when the original list was not empty.Exam application method
For a list-operation question, first write the list clearly. Mark the first element as the head and the remaining elements as the tail. Then state the operation and the resulting value, including brackets when the result is a list. For construction questions, show whether the new item is placed before every existing element (prepend) or after every existing element (append). For code questions, trace the list after each operation rather than describing only the final result.
Self-check
Can you explain why
[4, 3, 5]has tail[3, 5]rather than5? Can you state the head and tail of[7]? Can you give the length and empty-list result for[]? Can you predict the difference between prepending1to[2, 3]and appending1to[2, 3]? Can you identify whether each answer is an element, a list, a length, or an empty-list test result?- Returning the head produces the element
Ready to practise?
Choose your next step
Use the study guide for understanding, then switch into an active revision mode.
Related topics
