Fundamentals of Functional Programming | AQA A-Level Computer Science (7517)

Fundamentals of Functional Programming

  • 62 questions
  • 4 subtopics
  • Paper 2: the written exam
  • Paper 2

Function types, domain and co-domain, composition and partial application, higher-order functions, and lists built from a head and a tail.

Examined on Paper 2.

Sample questions from Fundamentals of Functional Programming

Answer each one closed book first, then open the answer.

  1. Function Types, First-Class Objects and Function Application

    Give the function type of a function that takes a character and returns whether it is a vowel, and identify the domain and co-domain.

    Show the answer
    isVowel: character → boolean. The domain is the set of characters, or a stated subset such as the lower-case letters; the co-domain is the set {True, False}. Here both members of the co-domain do occur as outputs, but that is a fact about this particular function and not a requirement of the notation.
  2. Partial Function Application and Composition

    With f(x) = x + 2 and g(y) = y³ as before, what is f ○ g, and what does the comparison show?

    Show the answer
    f ○ g = x³ + 2, because g is applied first, cubing the input, and then f adds 2 to that result. It is not the same function as g ○ f = (x + 2)³: with an input of 1, f ○ g gives 3 while g ○ f gives 27. This shows that composition of functions is not commutative in general, so the order in which the functions are written matters.
  3. Writing functional programs

    Give an example of filter applied to a list, showing the result.

    Show the answer
    Filtering the list [4, 7, 10, 13, 16] with the condition 'is even' gives [4, 10, 16]. In Haskell this is written filter even [4, 7, 10, 13, 16], which evaluates to [4, 10, 16]. The elements kept are unchanged and remain in their original order; only the ones failing the condition are absent.
  4. Lists in functional programming

    Can a list be empty, and how is the empty list written?

    Show the answer
    Yes, a list can be empty. In Haskell the empty list is written []. It is a perfectly good list; it simply has no elements, so it has no head and no tail. It is what remains after the last element has been removed, and it is the value a construction of a list starts from.

The 4 subtopics

One subtopic is one session. Work down the list.

Subtopic What it covers Questions
Function Types, First-Class Objects and Function Application Recall questions on function types, domain and co-domain, functions as first-class objects and why that matters, and function application and the type of a call such as add(3, 4). 14
Partial Function Application and Composition Recall questions on partial function application and how its types are written and grouped, practical reasons to use it, and composing functions and working out g ○ f and f ○ g. 14
Writing functional programs Recall questions on map, filter and reduce, what each does to a list of n elements, and composing them to answer a question about a set of data. 16
Lists in functional programming Recall questions on the head and tail of a list, the empty list, what happens when the head of an empty list is requested, and the seven basic list operations. 18
Fundamentals of Functional Programming is 62 of the 1,516 questions in the guide.Get the guide, £9

How the guide is worked

Answering a question from memory stores it far better than reading the answer again. The guide runs that as a fixed procedure on one subtopic at a time, about twenty minutes a session.

  1. Step 1 · Closed book

    Cover the answers. Work through one subtopic and write down what you can. Leave blanks where you have nothing.

  2. Step 2 · Open book

    Go back to the top. Read each printed answer and write it out in full, including the ones you had right.

  3. Step 3 · Closed book again

    Same questions, same order, from memory. The gap between pass one and pass three is the session result.

Read the full method, the return schedule and the research behind it.

Nearby topics

All 13 topics Guide overview

AQA A-Level Computer Science Active Recall Guide

Every topic, not just this one. 1,516 questions with their answers.

£9 GBP
Get the guide

Digital PDF, sent to the email address on your order.