Functional programming Flashcards
Function definition
A rule that for, for each element in some set A of inputs, assigns an output chosen from set B, but whithout necessarily using every member of B.
Define an argument
A piece of data that is passed to a function, and the rule is applied to the argument, creating the return value.
What is applied to the argument after it is passed to a function?
The rule
What possible forms could an argument take?
A number (pos, neg, decimal) Character Or any other data type. Another function if the language supports it.
Concerning using an argument as another function, what will the function need to do?
Will specify what data type is required for the argument.
If f is the function, A is the input and B is the output, define the function type
f : A -> B
In the function type F : A -> B what is A?
The argument type
In the function type F : A -> B what is B? What is A?
What does this mean?
B = The result type. A = the argument type
This means that function f maps A to B.
What do we describe the set of inputs (A) (the argument) as?
The domain.
Whaf do we describe the set of outputs (B (the return type) as?
The co-domain.
What must we remember about co-domains?
Not all members of the co-domain have to be used as outputs.
how can functionalities of f be changed?
If f has a different function type
First class object definition
Objects which may: appear in expressions Be assigned to a variable Be assigned to arguments Be returned in function calls
What are functions known as in functional programming?
First class objects.
What do some imperative languages support? What does this mean?
Functions as first class objects.
Functions can be passed as arguments or returned as the result of another function.