4.12.1.1 Function type and 4.12.1.2 First-class object Flashcards
1
Q
What is a function?
A
a rule that, for each element in some set A of inputs, assigns an output chosen from set B
A -> B where A is the domain and B is the codomain
A is the argument type, a value passed
B is the result type
some functions are predefined, some are user defined
2
Q
What is the domain / co-domain?
A
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.
3
Q
What is a first class object?
A
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 e.g integers, floating-point values, characters and strings
4
Q
Why are functions first class objects?
A
It can be an argument to another function as well as the result of a function call.