What does the reduce function do in functional programming?
a) Increases the size of a list
b) Transforms a list into a single value by applying a function cumulatively
c) Sorts elements in ascending order
d) Maps elements to their index
Answer:
b) Transforms a list into a single value by applying a function cumulatively
Explanation:
The reduce function applies a function cumulatively to the elements of a list, reducing the list to a single value (e.g., summing the elements).