Functional programming Flashcards
What type of functions does functional programming use?
Pure functions (Do not modify data, do no use variables, no function shares data with any other function)
What is functional programming useful for?
- Machine learning
- Processing big data
Name some higher order Haskell functions
- map
- filter
- fold
In (f: A → B), what part is the domain?
A
In (f: A → B), what part is the codomain?
B
Declared values or expressions are immutable. What does immutable mean?
Immutable means that they can’t be changed during program execution.
Name some examples of base types in Haskell (must be written with a capital)
- Integer
- Float
- Double
- Bool
- Char
What class object is a function?
A function is a first class object which can be an argument to another function as well as the result of another call.
What is function application?
Applying a function to its arguments
What is partial function application?
Applying part of a function to its arguments, splitting them up using brackets.
What is composition of functions?
Combining two functions together (indicated using a small circle ∘)
What is required for function composition to work?
The codomain of f must match the domain of g
g ∘ f: A -> C
How is function composition represented in Haskell?
(A.B)
What is a higher order function?
a function that takes one or more functions as arguments and/or returns a function as its result. (map, filter, fold)
What does the ‘map’ higher order function do in Haskell?
Applies a function to every element in the list.
> map (^2) [20, 3, 51, 6, 3, 7]
[400, 9, 2601, 36, 9, 49]