Functional Programming Flashcards

1
Q

What is the main problem of big data?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a programming paradigm + examples?

A

A way of computer programming
- Procedural
- Object Oriented
- Declarative
- Functional

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the basics of functional programming?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the advantages of functional programming?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q
A
  • The function f(x) = x^2
  • Draws a number from domain and then finds and maps the result integer in the codomain
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are domains and co-domains?

A
  • They are subsets of objects
  • Can be any data type
  • Used in functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
A

A - Domain / Input
B - Augument Type
C - Function
D - Result type
E - Domain to Co-domain mapping
F - Co-domain / Output

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a first class object and how is it used in functional programming?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a function application?

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How would you call a function application?

A
  • addThreeInts x y z = x + y + z
  • addThreeInts 6 2 5
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How does functions and arguments work in function application?

A
  • Function only takes one argument
  • Then returns as it result a new function
  • Processing the remaining aurguments
  • Returning the final value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is partial function application?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the composition fo functions?

A
  • Where you combine two functions in oder to get a new function
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the notation for composition of two functions

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What are the requirements for two functions to undergo composition?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Exaplain this diagram line by line

A
17
Q

How does the composition operator work?

A
  • Passes one output of one function
  • Inputting it into the next function
  • Allowing for indepent function design, testing and implementation
18
Q

What are higher order functions?

A
  • Functions that either
  • Takes in a function
  • Or returns a function
  • Or Does both
  • EG - Map,Filter,Reduce or fold
19
Q

What is a map?

A
  • Function that takes in two aurguments as inputs
  • A Function and a list
  • Function is applied toeach item in the list to produce a new list
20
Q

What is filters?

A
  • Takes in two aurguments as inputs
  • A predicate (to define a condition) as a function
  • A list
  • The Condition will then be applied to each item in the list
  • And create a new list with only items from the origonal list that match the condition
21
Q

What is fold/reduce

A
  • Applies function recursivly to item of a list to produce a singl value
  • You can supply an inital value which is combined with the fist elements from the list
  • Result can then be recursivly combined onto the next item and so on