Question 12
AQA Computer Science June 2023 Paper 2 (7517/2)A level4 marks
On the specification
- 12.1
- 4.12 Fundamentals of functional programming4.1 Fundamentals of programming
- 12.2
- 4.12 Fundamentals of functional programming
Question text
12 Figure 11 shows a function, FunctionZ, written in a functional programming language. Figure 11 FunctionZ [] = 0 FunctionZ (x:xs) = x + 2 * FunctionZ (xs) • [] is the empty list. • (x:xs) as the argument to a function splits a list into two parts, the head x and tail xs. 12.1 Complete Table 5 by writing the value of the argument passed to each call of FunctionZ and the value returned by each call, when FunctionZ [4, 2, 5, 3] is evaluated. [3 marks] Table 5 Call number Argument Value returned 1 [4, 2, 5, 3] 2 3 4 5 12.2 All of the values in lists passed to FunctionZ as the argument are members of the set of integers. Shade one lozenge to indicate the co-domain of the function. [1 mark] A The set of integers B The set of irrational numbers C The set of natural numbers D The set of rational numbers E The set of real numbers