12: Fundamentals of Functional Programming Flashcards

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

f: A → B

A

Function type is A → B, A is the argument type and the domain and B is the result type and the co-domain

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

The domain and co-domain are always ____

A

Subsets of objects in some data type

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

First-Class Object

A

A function in functional programming and in imperative programming languages that support such objects

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

First-Class Objects May (4)

A
  • Appear in expressions
  • Be assigned to a variable
  • Be assigned as arguments
  • Be returned in function calls
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Partial Function Application

A

Where a function, taking multiple arguments, is parsed less arguments so returns a function, which takes the missing arguments, before returning a value

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

Partial Function Notation (5)

A
  • The function add takes two integers as arguments and gives an integer as a result
  • add: integer → (integer → integer)
  • add 4 returns a function, which when applied to another integer, adds 4 to that integer
  • The brackets may be dropped: add: integer → integer → integer
  • The function add is now viewed as taking one argument after another and returning a result of data type integer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Composition of Functions (4)

A
  • The operation functional composition combines two functions to get a new function
  • Given two functions:
    f: A → B
    g: B → C
  • The function g ⚬ f, called the composition of g and f, is a function whose domain is A and co-domain is C
  • f is applied first and then g is applied to the result returned by f
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Head

A

The first element of a list

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

Tail

A

The list of all elements apart from the head

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

Prepend

A

Adds a single item, of the same data type as those in the list, to the start of the list

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

Append

A

Adds a list of items, with the same data type as those in the other list, to the end of the other list

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

Higher-Order Function

A

A function that takes a function as an argument or returns a function as a result, or does both

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

Map

A

A higher-order function that applies a given function to each element of a list, returning a list of results

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

Filter

A

A higher-order function that processes a data structure, typically a list, in some order to produce a new data structure containing exactly those elements of the original data structure that match a given condition.

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

Reduce / Fold

A

A higher-order function which reduces a list of values to a single value by repeatedly applying a combining function to the list values

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