12 - Fundamentals of Functional Programming Flashcards

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

Explain the purpose of the fold function in a functional programming language.

A

It reduces a list of values to a single value by applying a combining function.

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

Explain what a higher-order function is.

A

A function that takes a function as an argument or returns a function as a result.

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

What is map?

A

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

eg. map (*2) [1,2,3] outputs [2,4,6]

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

What is 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.

eg. filter (<5) [1,4,6] outputs [1,4]

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

What is 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 of values.

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

What is the head of a list?

A

The first element in the list

eg the head of [1,2,3] is 1

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

What is the tail of a list?

A

A list containing each element other than the first element of the list

eg the tail of [1,2,3] is [2,3]

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