Functional Languages (L14) Flashcards

1
Q

The design of imperative languages is based directly on which architecture model?

A

Von Neumann
architecture.

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

Does the Von Neumann architecture prioritize suitability for software development, or efficiency?

A

Efficiency.

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

Define the mathematical function.

A

it is a mapping of members of one (domain) set, to another (range) set.

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

C, Python, and Java functions are better described as?

A

Procedures.

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

What difference is there between procedures and true functions?

A

Procedures produce side effects (not pure mappings).

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

Does the modification of a global variable within a function count as a side effect?

A

Yes.

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

What term is used to refer to the consistency of a function’s output?

A

Referential integrity.

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

Do procedures in C, Python or Java have referential integrity?

A

They might - not neccesarilly, as is the case for pure functions.

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

Do side effects affect the evaluation order of statements?

A

Yes - the elimination of side effects generally reduce the importance of evaluation order.

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

Are functional languages used in industry?

A

Not as much as imperative languages.

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

Are functional languages used in research?

A

Mostly, yes.

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

Do imperative or functional languages have greater correctness?

A

Functional, and thus functional languages are more reliable.

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

In what way does correctness impact concurrency?

A

Correct functions do no manipulate global state, and thus they may be executed concurrently.

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

What’s a higher-order function?

A

A function that takes functions as parameters and/or yields a function as its result.

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

What’s a functional form?

A

Same as a higher order function.

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

“First class functions” refers to what type of functions?

A

Functions that can be used in the same way as any basic data type.

17
Q

Why don’t C’s function pointers count as first class functions?

A

Because C requires explicit prototyping when passing functions as parameters, and is much more fragile when using functions as types.

18
Q

Does Python support first class functions?

A

Unlike C, Python does support first class functions.

19
Q

Function composition is a functional form that does what?

A

That yields a function whose value is the first parameter (function) applied to the application of the second.

20
Q

Does C support function composition?

A

No.

21
Q

Do functional languages rely on iteration or recursion?

A

Recursion, but they often provide mechanisms for looping as well.

22
Q

Apply-to-all functionality in functional languages is commonly provided by a function called?

A

Map

23
Q

Why are data structures in functional languages generally immutable?

A

Such that global state does not change, and thus correctness is maintained.

24
Q

Due to data structure immutability in functional languages, do modifications produce entirely new copies?

A

No, modifications are more efficiently implemented.

25
Q

How are pure functional languages defined?

A

As collections functions with no imperative constructs or mutability.

26
Q

What type of programming language is Haskell?

A

Pure functional.

27
Q

What type of programming language is Clojure?

A

A hybrid of functional and imperative.