11 - Fundamentals of Functional Programming Flashcards
What is a programming paradigm?
A method of programming.
What are declarative programming languages?
Languages that declare or specify what properties a result should have.
What are procedural programming languages?
Languages where the programmer specifies the steps that must be carried out to achieve a result.
What is the problem with procedural programming languages?
The value of a variable can change throughout the program, which may impact several subroutines negatively.
What is the functional programming paradigm?
Where each line of code is made up of calls to a function, which may in turn be made of other functions or return a value.
What are the advantages of functional programming?
Allows programs to be defined as a series of abstractions based on other functions, rather than a complex series of steps.
Abstractions lead to fewer errors in implementation.
Functions are re-usable
No concurrency issues.
Easier to test and debug.
What is a function type?
It describes the structure of a function, including the data type of the parameters and output.
What is the domain of a function?
The set of data of the same type, which are inputs of a function.
What is the co-domain of a function?
The set of values from which the output values are chosen.
What is the range of a function?
The actual values used in the output of a function.
What does a function do?
Maps the domain to the co-domain.
What is the partial application of a function?
Process of partially applying a function to create an intermediate function that performs part of the calculation.
What is function composition?
The process of creating a new function by combing existing functions together.
What is a first-class object?
Any object that can be used as an argument or as the result of a function call.
What is a higher order function?
A function that takes a function as its argument or produces a function as the result or both.
What does the map function do?
Applies a function to every element within a list and returns a list of results.
What does the filter function do?
Processes a list and creates a new list whose elements match certain criteria.
What does the fold function do?
Takes a list of values and reduces it to a single value, by a recursive process where the function is processed until the list is empty.
What does foldr do?
Perform the fold function from the rightmost value.
What does foldl do?
Perform the fold function from the leftmost value.
What is a list?
A collection of data items of the same type.
What is an identifier?
The name given to a list.
What is the head of a list?
The first element in a list.
What is the tail of a list?
All elements in a list apart from the head.