Functional Programming Flashcards

1
Q

Define functional programming

A

Functional programming is a programming paradigm that binds all data to pure mathematical functions. Rather than storing and transforming data within a program, a functional program will instead display the result of a computation applied to the input values given to the function.

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

What are some benefits of functional programming?

A
  • Data represented by functional programming is immutable
  • Functional programs do not need to account for shared state
  • Prevents side effects within a program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a pure function?

A

Pure functions are simply functions that are immutable. Given the same input they will always return the same output.
They will also never produce side effects because they do not change any other data inside of a program.

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

Define Recursion.

A

Recursive functions are functions that will continually call themselves until a base case is reached.

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

Explain Referential Transparency

A

Referential Transparency is the idea that any value or expression can be replaced by any other value or expression that results in the same value.

This concept is important to functional programming because pure functions should only represent a data value within a program without modifying other parts of the program.

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

Explain the statement: Functions are First-Class

A

This means that functions can behave as variables and can be used in a similar way.

This is possible because of the fact that given acceptable parameters, pure functions will return some sort of data that can be used within the program

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

Why are functions considered to be immutable data?

A

Data returned by a function is not being stored anywhere, rather it is simply what was returned after a defined computation was preformed on one or more inputs. Due to this fact, the data being returned cannot be changed manually.
In order to receive a different result, the programmer would have to change the inputs, or modify the function.

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

What is the Declarative Programming Model

A

A programming paradigm that expresses the logic of a computation without describing its control flow.

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