Skip to content
Marlbridge

Flashcards · 7517 · Topic 12

Fundamentals of functional programming flashcards

7 cards on Topic 12. Pick a subtopic or study them all.

Study mode needs JavaScript. Every card is listed below, so you can still cover the answers and test yourself.

All 7 cards

For a quick read-through or printing. Cover the right-hand side to test yourself.

Topic 12: Fundamentals of functional programming

What is a function in functional programming?
A rule that maps each value in its domain to a value in its co-domain, written f: A → B. It has no side effects: the same input always gives the same output.
What does it mean that functions are first-class objects?
They can be assigned to variables, passed as arguments, and returned as the results of other functions.
What is a higher-order function?
A function that takes a function as an argument, returns a function, or both. Examples: map, filter and reduce (fold).
What do map, filter and reduce (fold) do?
Map: applies a function to every item of a list, giving a new list. Filter: keeps the items that meet a condition. Reduce/fold: combines the items into one value using a function, e.g. a sum.
What is partial function application?
Fixing some of a function’s arguments to produce a new function of the remaining arguments, e.g. add 3 gives a function that adds 3 to its argument.
What is function composition?
Combining two functions so that the output of one becomes the input of the other: g ∘ f means apply f, then g.
What are the head and tail of a list?
Head: the first element. Tail: the list of everything after the first element. Head of [4, 3, 5] is 4; tail is [3, 5].