Skip to main content
EnglandComputer ScienceSyllabus dot point

What is functional programming and how does it differ from imperative programming?

Understand the functional programming paradigm, functions as first-class objects, function application, partial application and composition, and the higher-order functions map, filter and reduce.

A focused answer to AQA A-Level Computer Science 4.13, covering the functional programming paradigm, functions as first-class objects, function application, partial application and composition, and the higher-order functions map, filter and reduce.

Generated by Claude Opus 4.89 min answer

Reviewed by: AI editorial process; not yet individually human-reviewed

Have a quick question? Jump to the Q&A page

Jump to a section
  1. What this dot point is asking
  2. The functional paradigm
  3. First-class functions, application, partial application and composition
  4. Higher-order functions: map, filter and reduce

What this dot point is asking

AQA wants you to describe the functional programming paradigm, explain that functions are first-class objects, describe function application, partial application and composition, and use the higher-order functions map, filter and reduce (fold).

The functional paradigm

The avoidance of mutable state is the heart of the paradigm and the source of its advantages. Because a pure function cannot alter anything outside itself, its behaviour depends only on its arguments, so it can be tested in isolation, its result can be cached, and several pure functions can run on different processors at once without interfering. This contrasts sharply with the imperative paradigm covered in the languages topic, where the program proceeds by changing the values of variables step by step.

First-class functions, application, partial application and composition

These ideas build on one another. First-class status is the foundation, because only if functions are values can you pass them around to build higher-order functions, compose them, or partially apply them. Partial application and composition are two different ways of making new functions from existing ones: partial application fixes arguments, while composition wires outputs into inputs. Keeping the two clearly apart is a frequent exam discriminator.

Higher-order functions: map, filter and reduce

map(double, [1,2,3])        -> [2,4,6]
filter(isEven, [1,2,3,4])   -> [2,4]
reduce(add, [1,2,3,4], 0)   -> 10

These three higher-order functions replace many of the explicit loops of imperative programming with a declarative description of what should happen to the data. Instead of writing a loop that mutates an accumulator, you state that you want every element transformed (map), or the matching ones kept (filter), or all of them combined (reduce). They are often chained: filter the even numbers, then map them to their squares, then reduce by addition, expressing a whole pipeline without a single mutable variable.

Exam-style practice questions

Practice questions written in the style of AQA exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.

AQA 20194 marksExplain what is meant by saying functions are first-class objects in a functional language, and explain the difference between function composition and partial application.
Show worked answer →

Functions are first-class objects means a function is treated like any other value: it can be passed as an argument to another function, returned as the result of a function, and stored in a variable. This is what makes higher-order functions possible.

Function composition combines two functions so that the output of one becomes the input of the next: composing f and g produces a new function that applies g first and then f to the result. Partial application instead supplies only some of a function's arguments to produce a new function that takes the remaining arguments; for example fixing the first argument of an add function to make an addFive function.

Markers reward the pass-return-store description of first-class functions and a clear distinction between composition (chaining outputs to inputs) and partial application (fixing some arguments to create a new function).

AQA 20214 marksDescribe the higher-order functions map, filter and reduce, and state the result of applying each to the list [1, 2, 3, 4] with a suitable function.
Show worked answer →

A higher-order function is one that takes a function as an argument or returns a function. Map applies a given function to every element of a list and returns a new list of the results. Filter returns a new list containing only the elements that satisfy a given condition. Reduce (fold) combines all the elements into a single value using a given function and a starting value.

Examples on [1, 2, 3, 4]: map with a doubling function gives [2, 4, 6, 8]; filter with an is-even test gives [2, 4]; reduce with addition and a start of 0 gives 1 + 2 + 3 + 4 = 10.

Markers reward correct descriptions of all three higher-order functions and correct results for the worked examples.

Related dot points

Sources & how we know this