Learning objective
Partial function application: Know what is meant by partial function application for one, two and three argument functions and be able to use the notations shown opposite. The function add takes two integers as arguments and gives an integer as a result. Viewed as follows in the partial function application scheme: add: integer → (integer → integer) add 4 returns a function which when applied to another integer adds 4 to that integer. The brackets may be dropped so function add becomes add: integer → integer → integer The function add is now viewed as taking one argument after another and returning a result of data type integer. 92
Read the explanation, check the common trap, then practise with flashcards and questions.
At a glance
0
Flashcards
0
Questions
Topic
Functional programming paradigm
Subtopic
Partial function application
Study support
Understand this objective
Quick explanation
Partial function application: Know what is meant by partial function application for one, two and three argument functions and be able to use the notations shown opposite. The function add takes two integers as arguments and gives an integer as a result. Viewed as follows in the partial function application scheme: add: integer → (integer → integer) add 4 returns a function which when applied to another integer adds 4 to that integer. The brackets may be dropped so function add becomes add: integer → integer → integer The function add is now viewed as taking one argument after another and returning a result of data type integer. 92
- This point belongs to Functional programming paradigm, especially Partial function application.
- You need to be able to partial function application: Know what is meant by partial function application for one, two and three argument functions and be able to use the notations shown opposite. The function add takes two integers as arguments and gives an integer as a result. Viewed as follows in the partial function application scheme: add: integer → (integer → integer) add 4 returns a function which when applied to another integer adds 4 to that integer. The brackets may be dropped so function add becomes add: integer → integer → integer The function add is now viewed as taking one argument after another and returning a result of data type integer. 92.
- Use the linked flashcards and practice questions to check recall, then practise applying the idea in an exam-style answer.
Why it matters
This objective helps connect Partial function application to exam-style questions, flashcards, and revision notes for Functional programming paradigm.
Quick student answer
Which type best represents the function add when it is viewed as taking one integer argument after another and returning an integer result?
Direct answer
integer → integer → integer
Key terms
- Partial function application: Applying fewer arguments than a function requires, producing another function that accepts the remaining arguments.
- Function type notation: Notation using arrows to show the sequence of argument types and the final result type, such as integer → integer → integer.
Common trap
Treating a partially applied function as the final result: Recognise that add 4 is a function of type integer → integer. It needs another integer before the final integer result is produced.
Related questions
Try this as a practice card
Question 1 of 4
Choose an answer, get feedback, then move sideways through the set.
Flashcard prompts
Flip through the key recall cards
Flashcard 1 of 4
Revision tools
Choose how to practise
Flashcards0 linked cards
Practice Questions0 linked questions
Related learning objectives
- Function type: Know that a function, f, has a function type f: A → B (where the type is A → B, A is the argument type, and B is the result type). Know that A is called the domain and B is called the co-domain. Know that the domain and co-domain are always subsets of objects in some data type. Loosely speaking, a function is a rule that, for each element in some set A of inputs, assigns an output chosen from set B, but without necessarily using every member of B. For example, f: {a,b,c,…z} → {0,1,2,…,25} could use the rule that maps a to 0, b to 1, and so on, using all values which are members of set B. The domain is a set from which the function’s input values are chosen. The co-domain is a set from which the function’s output values are chosen. Not all of the co-domain’s members need to be outputs.
Function type
- First-class object: Know that a function is a first-class object in functional programming languages and in imperative programming languages that support such objects. This means that it can be an argument to another function as well as the result of a function call. First-class objects (or values) are objects which may: • appear in expressions • be assigned to a variable • be assigned as arguments • be returned in function calls. For example, integers, floating-point values, characters and strings are first class objects in many programming languages.
First-class object
- Function application: Know that function application means a function applied to its arguments. The process of giving particular inputs to a function is called function application, for example add(3,4) represents the application of the function add to integer arguments 3 and 4. The type of the function is f: integer x integer → integer where integer x integer is the Cartesian product of the set integer with itself. Although we would say that function f takes two arguments, in fact it takes only one argument, which is a pair, for example (3,4).
Function application
- Composition of functions: Know what is meant by composition of functions. The operation functional composition combines two functions to get a new function. Given two functions f: A → B g: B → C function g ○ f, called the composition of g and f, is a function whose domain is A and co-domain is C. If the domain and co-domains of f and g are ℝ, and f(x) = (x + 2) and g(y) = y3. Then g ○ f = (x + 2)3 f is applied first and then g is applied to the result returned by f.
Composition of functions
