Question 11

AQA Computer Science November 2020 Paper 2 (7517/2)A level7 marks

On the specification

11.1
4.12 Fundamentals of functional programming
11.2
4.12 Fundamentals of functional programming4.1 Fundamentals of programming
11.3
4.12 Fundamentals of functional programming
11.4
4.12 Fundamentals of functional programming
Question text

11 1 box . The list towers is defined as: towers = ["Blackpool", "Paris", "New Brighton", "Toronto"] What are the head and tail of this list? [1 mark] Head Tail 11.2 Figure 14 shows some code written in a functional programming language. Figure 14 total [] = 0 total (x:xs) = x + total (xs) The following notes are provided to help you understand the syntax of the code in Figure 14: • [] is the empty list • (x:xs) as the argument to a function splits a list into two parts, the head x and tail xs. Describe how the total function works to add up all of the numbers in a list. [3 marks] Functional programming languages support higher-order functions such as map and box fold. 11.3 Explain what a higher-order function is. [2 marks] 11.4 What is the result of this application of the fold function? fold (*) 1 [2, 3, 2] [1 mark] Result