Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
AQA A level Computer Science Teaching and Learning Resources Chapter 46 – Basics of functional programming TASK QUESTIONS (WITH ANSWERS) 1 Describe the basic properties of a function. An expression that takes an input value from a set and returns an output value from another set 2 Define the functional programming paradigm. Programming statements are written in the form of mathematical functions. 3 What are the main reasons for using functional languages compared to procedural languages? As a function always returns the same value given the same inputs, there are no ‘side effects’ where the value of the variable changes and can become difficult to trace. Functional programs lend themselves to problems that are mathematical in nature and therefore are often more efficient them procedural languages in these scenarios. Functional code can require less code to be written and are therefore more concise. This can lead to more elegant code, with fewer bugs. 4 What is a first-class object? Give two examples. A broad definition of a first-class object is any object that can be dynamically created, destroyed or passed as an argument. Examples include functions, integers and characters. 5 Show the full and partial application of the equation f = (a, b, c) = a + b - c with a set of integers. For example: a = 1, b = 2, c = 3 Partial application is f = a + b = 3 Full application is f = a + b – c = 0 6 Use function composition to combine the equation f(x) = x3 with g(x) = x + 3. f ◦ g becomes g(f(x)) =x3+3 AQA A level Computer Science © Hodder & Stoughton Limited 2015