What are higher-order functions, and how do map, filter and fold process lists in functional programming?
Higher-order functions and list processing: passing and returning functions, the map, filter and fold (reduce) operations, function composition, and how lists are processed by the head and tail.
An Eduqas Component 2 answer on higher-order functions: passing and returning functions, the map, filter and fold (reduce) operations, function composition, and processing lists by their head and tail.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
Eduqas wants you to explain higher-order functions, describe the map, filter and fold (reduce) operations and what each produces, explain function composition, and describe how lists are processed by their head and tail. These are the practical tools of functional programming, taught in Haskell.
The answer
Higher-order functions
Map, filter and fold
Function composition and head/tail processing
Examples in context
Map, filter and fold are everywhere in modern programming, not just Haskell: JavaScript, Python and Java all provide them, and they are the backbone of large-scale data processing frameworks (MapReduce, Spark) precisely because pure, composable operations parallelise so well. A web app might filter a product list by category, map each to a display card, and fold prices to a total, exactly the pipeline above. This builds directly on the functional paradigm and recursion, and shows why first-class functions matter.
Try this
Q1. What does the map operation produce when applied to a list? [1 mark]
- Cue. A new list of the same length, with the given function applied to (transforming) every element.
Q2. Define a higher-order function. [1 mark]
- Cue. A function that takes one or more functions as arguments, or returns a function as its result.
Q3. Using map, filter and fold, describe how to find the total of all numbers greater than in a list. [2 marks]
- Cue. Filter to keep numbers greater than , then fold with addition (starting value ) to sum them (map is not needed unless transforming first).
Exam-style practice questions
Practice questions written in the style of WJEC Eduqas exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
Eduqas 20216 marksExplain what a higher-order function is, and describe the map, filter and fold (reduce) operations, stating what each produces when applied to a list.Show worked answer →
Higher-order function (up to 2 marks): a function that takes one or more functions as arguments, or returns a function as its result; this is possible because functions are first-class values.
Map (up to 1 mark): applies a given function to every element of a list, producing a new list of the same length with each element transformed (for example doubling every number).
Filter (up to 2 marks): tests every element of a list against a given Boolean function (predicate) and produces a new list containing only the elements that satisfy it (for example keeping only the even numbers); the result may be shorter.
Fold/reduce (up to 1 mark): combines all the elements of a list into a single value using a given function and a starting value (for example summing a list to one total).
Markers reward the takes-or-returns-a-function definition, and correct descriptions of map (transform each, same length), filter (keep those passing a test), and fold (combine to a single value).
Eduqas 20225 marksA list of numbers is given. Using map, filter and fold, describe how you would calculate the sum of the squares of only the odd numbers in the list, and explain what is meant by function composition.Show worked answer →
Using the operations (up to 3 marks): first filter the list to keep only the odd numbers (a predicate testing oddness); then map the squaring function over the result to square each; then fold with addition and a starting value of to combine them into a single total.
Function composition (up to 2 marks): combining two or more functions so that the output of one becomes the input of the next, creating a new function; for example composing "square" after "filter odds" so the whole pipeline is a single function applied to the list.
Markers reward the filter-then-map-then-fold pipeline in a sensible order and a correct definition of composition (output of one function feeds the next).
Related dot points
- The functional paradigm: functions as first-class values, pure functions and referential transparency, immutability and the avoidance of side effects, the use of recursion instead of iteration, and how functional differs from imperative programming.
An Eduqas Component 2 answer on the functional paradigm: functions as first-class values, pure functions and referential transparency, immutability and avoiding side effects, recursion in place of iteration, and how functional programming differs from the imperative approach.
- Recursion and algorithmic complexity: the base case and recursive case, how recursion uses the call stack, and Big-O notation for the time and space complexity of algorithms (constant, logarithmic, linear, polynomial and exponential).
An Eduqas Component 1 answer on recursion and complexity: the base case and recursive case, how recursion uses the call stack and can cause stack overflow, and Big-O notation for measuring how an algorithm's time and space scale with input size.
- Procedural and object-oriented programming: subroutines (procedures and functions) with parameters and return values, and the object-oriented concepts of classes and objects, encapsulation, inheritance and polymorphism.
An Eduqas Component 1 answer on programming paradigms: procedures and functions with parameters passed by value or reference, and the object-oriented concepts of classes, objects, encapsulation, inheritance and polymorphism, with their benefits for large programs.
- Dynamic data structures: stacks (LIFO) and queues (FIFO) with their push, pop, enqueue and dequeue operations and pointer management, linear and circular queues, and singly and doubly linked lists with insertion and deletion.
An Eduqas Component 1 answer on stacks, queues and linked lists: LIFO and FIFO behaviour, push, pop, enqueue and dequeue with pointer management, the wrap-around in a circular queue, and inserting and deleting nodes in a linked list.
- Programming principles: primitive and composite data types, variables and constants, scope and lifetime, and the three programming constructs of sequence, selection and iteration used to build structured programs.
An Eduqas Component 1 answer on programming principles: the primitive data types, variables versus constants, local versus global scope and lifetime, type conversion, and the three programming constructs sequence, selection and iteration.