AQA 7517 4.12.2.1: Functional language programs
The free BugBot lessons that teach this point, a robot to try it on, and the past-paper questions that test it.
What it covers
In lesson A1.6 you met the idea of a programming paradigm, and wrote procedural and object-oriented programs. Both are imperative: a program is a sequence of statements that change the program's state, the values in its variables, one step at a time. This module is about a different paradigm. In functional programming a program is built from functions, in the mathematical sense: a function takes values in and gives a value back, and does nothing else. Languages built for it include Haskell, F#, Erlang and Clojure. Python is not a functional language, but it supports the style, so you can try every idea here in Python and compare it with Haskell.
- A function, in the mathematical sense
- Immutability
- Statelessness
- Where the robot fits
Or do it in the simulator, with tasks that mark themselves
Lessons that teach it
- A13.1 The functional paradigm Functional programming
Side effects, pure functions and referential transparency, immutability and statelessness, with the robot's side effects kept at the edges. - A13.3 First-class objects and higher-order functions Functional programming
Functions as values in variables, lists and dictionaries, passed as arguments and returned as results, lambdas, closures and a robot… - A13.5 Map, filter and fold Functional programming
The three higher-order functions, foldl and foldr, and a pipeline over a log of sensor readings. - A13.8 Project: the way out Functional programming
Sweep the bay, decide with a pipeline of pure functions built by composition, map, filter and fold, then drive out.
Try it on a robot
The task from A13.1 The functional paradigm, running here. Change the program and press Run.
The specification is AQA's own document; this page says which of our lessons teach point 4.12.2.1 and is not endorsed by the board.