Section 12 Chapter 69 - Functional Programming Flashcards
Programming Paradigm
A style of computer programming e.g. OOP
Procedural
Series of instructions that tell the computer what to do
Declarative
Written statements are implemented in a way that the programming language deems most appropriate
Functional programming
Functions are the building blocks of the program. Statements are written as a series of functions
Function
A rule or set of rules that maps values from the domain to the co-domain. A value from the domain is input tot the function and it returns a value from the co-domain
What do the domain and co-domain have in common (in terms of sets)
They are both subsets of objects in some data type
Domain
The set from which the functions input values are chosen
Co-Domain
The set from which the functions outputs are chosen. Not all the members of the co-domain need to be outputs
Can the domain and co-domain be of different data types
yessir
Function type
A -> B, where A is the argument type and B is the result type
Argument type
The data type of an argument of a function
Result type
The data type of the output of a function
First class object (4)
An object which can
- Appear in expressions
- Be assigned to a variable
- Be assigned as an argument
- Be returned by a function
What is the cool first class object in functional programming
functions!!1!!11 :O
What is the significance of functions being first class objects
They can be passed as an argument or returned by a function