You are on page 1of 1

1.

Compare and contrast the map, filter, and reduce

'Map' applies a given function to each item of an iterable (like a list or set)
and returns a list of the results. 'Filter' constructs a list from elements of an
iterable for which a function returns true. 'Reduce' applies a rolling
computation to sequential pairs of values in a list and returns a single result.
1. What's the important of using these three functions? (map, filter, and reduce).

Map/filter/reduce can often make code shorter and simpler and allow the
programmer to focus on the heart of the computation rather than on the
details of loops, branches, and control flow.
2. Describe the lambda function and what are the benefits of using lambda.

Lambda functions are similar to user-defined functions but without a name.


They're commonly referred to as anonymous functions. Lambda functions are
efficient whenever you want to create a function that will only contain simple
expressions – that is, expressions that are usually a single line of a statement.

Johaira.Isra@msumain.edu.ph

You might also like