Functional Programming Flashcards Preview

Software Developer Interview Prep > Functional Programming > Flashcards

Flashcards in Functional Programming Deck (10)
Loading flashcards...
1

What is functional programming?

Functional programming (often abbreviated FP) is the process of building software by composing pure functions, avoiding shared state, mutable data, and side-effects. Functions are first class citizens of such languages.

2

Which is imperative and which is declarative?

FP - Declarative and OOP - Imperative

3

Where does application state reside in FP vs OOP?

Application state flows through pure functions, as opposed to OOP where the state is usually shared and colocated with methods in objects.

4

Examples of some functional languages

LISP, Erlang, Haskell, F#, Clojure,

5

A pure function ____

- Given same input always returns same value
- Has no side effects

6

Function composition is ______

Is process of combining two or more functions to produce new function or produce some output.
f(g(x))

7

Shared state is ______

Any variable, object or memory that is shared scope or is a property of object being passed between scopes.

8

Problems with shared state

- To understand the behavior of function you need to know the history of every shared variable that function uses or affects
- Race condition

9

Examples of side effects

- Changing global variable or shared variable
- Logging to console
- Writing to file
- Writing to network
- Triggering any external process
- Calling other function that has side effects

10

What are higher order functions?

HOF is any function which takes function as argument, returns a function or both. They are at higher abstraction levels.
Eg. Monads, Promise, Async etc