Fundamentals of Functional Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is a function?

A

A rule that assigns an output from set B to each element in set A, without necessarily using every member of B.

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

Which of the following is not true of
first-class objects?
1. They can appear in expressions
2. They can be assigned to a data type
3. They can be assigned as arguments
4. They can be returned in function calls

A

They can be assigned to a data type

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

What is an argument in relation to a function?

A

An argument is a piece of data passed to a function for processing.

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

What does the DoubleMe function do?

A

DoubleMe takes an input and outputs its double. For example, DoubleMe 6 returns 12.

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

What is a function type?

A

A function type describes the argument type and result type of a function. It specifies the domain and co-domain of the function.

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

Provide an example of a function type.

A

The function f returns double the input. The domain is the set of natural numbers, and the co-domain is the set of even natural numbers.

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

What does it mean for functions to be first-class objects?

A

First-class objects can appear in expressions, be assigned to variables, be passed as arguments, and be returned as function results.

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

What is function application?

A

Function application is the process of applying the function rule to the arguments to obtain the output.

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

Explain partial function application.

A

Partial function application fixes one or more arguments of a function, creating a specialized version of the function.

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

What is functional composition?

A

Functional composition is the act of combining two functions to create a new function by connecting the output of one function to the input of another.

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

Can any two functions be composed together?

A

: Two functions can be composed if the domain of one function matches the co-domain of the other function.

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

What are higher-order functions?

A

Higher-order functions either take a function as an argument, return a function as its result, or both.

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

What is the map function?

A

The map function applies a second function to each element in a list and returns a new list with the transformed elements.

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

What is the filter function?

A

The filter function returns the elements of a list that satisfy a given condition.

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

What is the fold function?

A

The fold function, also known as reduce, combines the elements of a list into a single value using an operator and an initial value.

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

What is the difference between fold left and fold right?

A

Fold left processes the list from the left to the right, while fold right processes the list from the right to the left.

17
Q

What is the difference between fold left and fold right?

A

Fold left processes the list from the left to the right, while fold right processes the list from the right to the left.