Functional programming Flashcards

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

Function definition

A

A rule that for, for each element in some set A of inputs, assigns an output chosen from set B, but whithout necessarily using every member of B.

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

Define an argument

A

A piece of data that is passed to a function, and the rule is applied to the argument, creating the return value.

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

What is applied to the argument after it is passed to a function?

A

The rule

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

What possible forms could an argument take?

A
A number (pos, neg, decimal)
Character
Or any other data type. 
Another function if the language supports it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Concerning using an argument as another function, what will the function need to do?

A

Will specify what data type is required for the argument.

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

If f is the function, A is the input and B is the output, define the function type

A

f : A -> B

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

In the function type F : A -> B what is A?

A

The argument type

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

In the function type F : A -> B what is B? What is A?

What does this mean?

A
B = The result type. 
A = the argument type

This means that function f maps A to B.

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

What do we describe the set of inputs (A) (the argument) as?

A

The domain.

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

Whaf do we describe the set of outputs (B (the return type) as?

A

The co-domain.

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

What must we remember about co-domains?

A

Not all members of the co-domain have to be used as outputs.

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

how can functionalities of f be changed?

A

If f has a different function type

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

First class object definition

A
Objects which may:
appear in expressions
Be assigned to a variable
Be assigned to arguments
Be returned in function calls
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are functions known as in functional programming?

A

First class objects.

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

What do some imperative languages support? What does this mean?

A

Functions as first class objects.

Functions can be passed as arguments or returned as the result of another function.

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

Outline examples of first class objects

A

Integers
Floating point values
Characters
Strings

17
Q

Define function application

A

Applying the function rule to the arguments of the function

18
Q

How many arguments do functions take in functional programming?

A

One - (3,5 = a pair = one).

19
Q

What is a partial function

A

Takes advantage of the inability of a function to take more than one input.

20
Q

Outline arguments in a partial function

A

One of the arguments is fixed, leading to a more restricted, specialised function.

21
Q

What is functional composition

A

The act of combining two functions to create a new function.

22
Q

What is the benefit of a function composition?

A

The user is able to use the functions both seperately and in conjunction.

23
Q

What is the condition that must be met for two functions to be combined?

A

As long as domain of one of the functions is the same as the co-domain of the other.

24
Q

Symbol that imdicates two functions are being combined

A