Programming: Functional Programming Flashcards

1
Q

Which higher order function can be described as ‘takes in two arguments as inputs, a function and a list, and applies the function to each value in a list’?

A

Map

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

Describe the meaning of a function

A

A rule that for each element in set A of inputs, an output is chosen from set B, not necessarily using all of set B

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

How does a function function?

A

An argument is passed into a function and a rule is applied to the argument to generate a return value.
The data type will be specified by the function.
(The input to a function could even be another function)

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

How can function types be written?

A

f: A –> B

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

In the function type f : A —> B , what is A and B?

A

A is the argument type. The set of inputs, domain
B is the result type. Set of outputs, co-domain

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

What is the domain of a function?

A

The set of values that can be input

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

Describe the concept of first class objects in programming

A

An entity that can be constructed at run-time, passed as a parameter, returned from a function or assigned into a variable.

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

What is a first class object? (AQA version)

A

Objects that can:
-appear in expressions
-be assigned to variables
-be assigned as arguments (passed as parameters)
-be returned in function calls

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

Describe function application

A

Applying the function rule to arguments of a function

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

What is a limitation of a function?

A

It can only take one input

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

Why is partial function application beneficial?

A

It takes advantage of the fact that functions can only take one input.

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

How can partial functions be used to solve the multiple inputs problem?

A

In partial functions one of the values is fixed.

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