In functional programming, what does the map function do?

In functional programming, what does the map function do?

a) Transforms each element in a list using a function and returns a new list
b) Filters out elements from a list
c) Sorts the elements in a list
d) Modifies the original list in place

Answer:

a) Transforms each element in a list using a function and returns a new list

Explanation:

The map function applies a given function to each element in a list and returns a new list with the transformed values.

Reference:

Functional Programming Quiz – MCQ Questions and Answers

Scroll to Top