logo

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

AqaA LevelComputer ScienceFundamentals of 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 is 4 and the tail is [3, 5]. Applying the same description to the tail gives a new head of 3 and 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].

    1. Returning the head produces the element 4.
    2. Returning the tail produces the list [3, 5].
    3. Testing whether values is empty produces false, because it contains elements.
    4. Returning its length produces 3.
    5. Prepending 2 produces [2, 4, 3, 5]; the new item becomes the head.
    6. Appending 2 produces [4, 3, 5, 2]; the existing head remains 4.

    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 is 0, and an empty-list test should identify it as empty. A single-element list such as [7] has head 7 and 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 than 5? 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 prepending 1 to [2, 3] and appending 1 to [2, 3]? Can you identify whether each answer is an element, a list, a length, or an empty-list test result?

Ready to practise?

Choose your next step

Use the study guide for understanding, then switch into an active revision mode.