Question 6
AQA Computer Science June 2017 Paper 2A level5 marks
On the specification
- 6.1
- 4.12 Fundamentals of functional programming
- 6.2
- 4.12 Fundamentals of functional programming
- 6.3
- 4.12 Fundamentals of functional programming
Question text
6 In a functional programming language a function named square and three lists a, b and c are defined as follows. square x = x * x a = [1, 3, 5] b = [1, 5, 10, 15] c = [9, 7, 2] 6.1 What is the list or value that is the result of applying the functions head(tail(tail b))? [1 mark] 6.2 Calculate the results of making the function calls listed in Table 2 with the lists a, b and c above. [3 marks] Table 2 Function Call Result map square a filter (<10) b fold (+) 0 c 6.3 map is an example of a higher-order function. Explain what a higher-order function is. [1 mark]