Functional Programming Flashcards

1
Q

What is functional programming?

A

Functional programming removes interdependencies between programs by replacing procedures with pure functions that use shared and immutable states. Functional programming languages include Lisp, Erlang, Haskell, and Clojure.

Example: Haskell is a functional programming language.

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

What is a pure function?

A

A pure function is one that, given the same inputs, always returns the same output and has no side effects. It doesn’t modify any global variables, ensuring the program’s behavior is predictable.

Example: The function add(a, b) => a + b is a pure function.

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

What is a side effect?

A

A side effect refers to any application state change that is observable outside the code function, other than its return value. This includes modifying any external variables or object properties, such as a global variable or a variable in the parent function’s scope. Writing to a screen or file are also examples of side effects.

Example: Modifying a global variable within a function is a side effect.

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

What is shared state?

A

Shared state refers to variables that can be accessed by more than one function. In object-oriented programming, objects are often shared between programs and functions by adding properties to other objects. Functional programming relies on immutable data structures and pure calculations to derive new data from existing data.

Example: Shared state can lead to timing dependencies in functional programming.

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

What is immutability?

A

An immutable object is one that cannot be modified after it is created. Immutability is a crucial concept in functional programming because without it, data flow in your program can be disrupted, leading to strange bugs.

Example: Strings in many programming languages are immutable.

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

What is an algorithm?

A

An algorithm is a set of instructions for solving a problem or accomplishing a task. A good algorithm should be clear, unambiguous, practical, and interpretable in any programming language.

Example: Sorting algorithms like bubble sort and quicksort are common examples of algorithms.

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

What is a code editor?

A

A code editor is a program specialized for writing software. Key features include syntax highlighting, indentation, autocomplete, and brace matching.

Example: Visual Studio Code is a popular code editor.

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

What is the command line?

A

The command line is a powerful text-based interface that developers use to communicate with computers efficiently. Most operating systems come with a command line, and you can also download third-party ones with additional functionality.

Example: Command Prompt in Windows is a command line interface.

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

What are some examples of text editors?

A

Text, TextMate, UltraEdit, Visual Studio Code, and many others.

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

What is the command line?

A

A powerful text-based interface that developers use to communicate with computers efficiently.

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

What are some common command line commands?

A

cd (change directory), mv (move), cp (copy), touch (create a file), mkdir (make directory), and clear (clear the screen).

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

What is an operating system (OS)?

A

The most important software that runs on a computer, managing the computer’s memory, processes, software, and hardware.

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

What are some well-known operating systems?

A

Windows, macOS, and Linux.

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

What is Linux known for?

A

Being a family of open-source operating systems that can be modified and distributed by anyone.

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

What are some popular Linux distributions?

A

Ubuntu, Debian, Kali, and Mint.

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

What are some resources engineers use to find answers?

A

Google, Stack Overflow, Mozilla Developer Network, W3Schools, Stack Exchange, and Reddit channels like r/programming and r/webdev.

17
Q

Why is it important for engineers to collaborate with others?

A

To connect with peers who can assist with questions and provide support.