Functional Programming Flashcards
What is the main problem of big data?
- Variety prevents relational databses to be used
- As data cannot be put into columns and rows
- With relational databases not being practical
- Machine learning is allows for big data analysis
What is a programming paradigm + examples?
A way of computer programming
- Procedural
- Object Oriented
- Declarative
- Functional
What are the basics of functional programming?
- Functions are the fundemtal building blocks
- Statements are written as a series of function
- Where each acepts parameters and returns an output
- Variables stateless and immutable meaning they cannot change
- Functions can only perform a calculaion and then return a value meaning there is no side effects
What are the advantages of functional programming?
- Code is easier to understand
- Easier to predict outcomes allowing for easier debugging
- Less prone to bugs
- Aids parallel processing where programs can be run across multiple machines
- The function f(x) = x^2
- Draws a number from domain and then finds and maps the result integer in the codomain
What are domains and co-domains?
- They are subsets of objects
- Can be any data type
- Used in functions
A - Domain / Input
B - Augument Type
C - Function
D - Result type
E - Domain to Co-domain mapping
F - Co-domain / Output
What is a first class object and how is it used in functional programming?
- Functions in functional programming is a fire class object
Any Object - In procedural langagues they are (inegers, arrays, strings, ect)
- That can be assigned a variable
- Appear in expressions
- Can be returend in a function
- Can be asssigned as an aurgument
What is a function application?
- The process of giving particular inputs to a function
- Where they apply or call the function
- Using function name followed bt the arguments with spaces
How would you call a function application?
- addThreeInts x y z = x + y + z
- addThreeInts 6 2 5
How does functions and arguments work in function application?
- Function only takes one argument
- Then returns as it result a new function
- Processing the remaining aurguments
- Returning the final value
What is partial function application?
- Process of decomposing multi-argument functions
- Into smaller functions with less auguments
- Where you bind the value of some inputs to a function to produce more specific solution
What is the composition fo functions?
- Where you combine two functions in oder to get a new function
What is the notation for composition of two functions
What are the requirements for two functions to undergo composition?
- The co-domain of the first function must be the same as the domain of the second function
- L’s codomain is B, K’s domain is B