Programming: Functional Programming Flashcards
Which higher order function can be described as ‘takes in two arguments as inputs, a function and a list, and applies the function to each value in a list’?
Map
Describe the meaning of a function
A rule that for each element in set A of inputs, an output is chosen from set B, not necessarily using all of set B
How does a function function?
An argument is passed into a function and a rule is applied to the argument to generate a return value.
The data type will be specified by the function.
(The input to a function could even be another function)
How can function types be written?
f: A –> B
In the function type f : A —> B , what is A and B?
A is the argument type. The set of inputs, domain
B is the result type. Set of outputs, co-domain
What is the domain of a function?
The set of values that can be input
Describe the concept of first class objects in programming
An entity that can be constructed at run-time, passed as a parameter, returned from a function or assigned into a variable.
What is a first class object? (AQA version)
Objects that can:
-appear in expressions
-be assigned to variables
-be assigned as arguments (passed as parameters)
-be returned in function calls
Describe function application
Applying the function rule to arguments of a function
What is a limitation of a function?
It can only take one input
Why is partial function application beneficial?
It takes advantage of the fact that functions can only take one input.
How can partial functions be used to solve the multiple inputs problem?
In partial functions one of the values is fixed.