Latest News

Monday, May 30, 2022

Difference between Map(),filter() and reduce () functions

 Map():Map(function,iterable)

Map function takes a function and an iterable as arguments and applies on each element of vector separately.

The returned value from map object can be passed to functions like list(),set() etc to get values from map object.


Filter():The filter function operates on a list and returns a subset of that list after applying filtering rule.

reduce():The reduce function will transform a given list into a single value by applying a given function continuously to all the elements.


You have to import reduce () from functools ,otherwise below error will be thrown saying 'reduce' is not defined.





  • Google+
  • Pinterest
NEXT »

No comments

Post a Comment