Python: Lambda, Map, Filter, Reduce Functions



An intro to functional programming in Python 3 covering Lambda, Map, Filter and Reduce functions.

RELATED VIDEOS:
► Lambda Functions:
► Lambda Map Filter Reduce:
► Unpacking Variables:
► Iterating Lists:
► Generators:
► Progress Bar:
► Datetime & Timestamp:
► HTTP Requests & Web APIs:
► List Comprehensions:
► Set Comprehensions:
► All about Strings:
► String Format:
► Recursion:
► Exception Handling:
► Debugger:

► Twitter:
► Subscribe:
► Thank me on Patreon:

#Python

Nguồn: https://benjaminjcohen.com/

Xem thêm bài viết khác: https://benjaminjcohen.com/cong-nghe/

25 Comments

  1. FYI Python 3.x.x users, reduce was moved to functools. (from functools import reduce)

  2. so easy to follow, great job!
    for the last part: i think the code needs to be updated and import functools
    import functools

    print(functools.reduce(lambda x,y:x*y,n))

  3. javascript and python is somewhat similar

  4. Subbed. Don't know why Youtube hasn't brought me to your channel before. Your explanation helped me understand three functions (two of which I hadn't even heard of) that I didn't understand before. Thank you.

  5. This was very useful. Thank you

  6. If I'm not mistaken you could also return x if x > y else y from the regular def function right?

  7. Your example at 5:25 minuts:
    n = [4, 3, 2, 1]
    def square(lst1):

    lst2 = []

    for i in lst1:

    lst2.append(i ** 2)

    return lst2

    print(list(map(square, n))) — > This doesnt work. It gives TypeError: 'function' object is not iterable.

  8. MAP can be a FILTER?? just changing the func??

  9. Good explanations. Thanks.

  10. Joe, you just helped me understand Lambda and other functions. This will be the easiest explanation I have seen so far. (a week into Python programming)

  11. Isn't map and filter kind of not really that useful because of list comprehension? It tends to be faster afaik to use list comprehension.

    lst = [1, 3, 5, 7, 9]
    ret =[x for x in lst if x > 2]

  12. Very helpful sir. Hope a lot of students will learn something from it. Regards, love and affection.

  13. So it seems like list comprehension can do everything that a lambda can do. It would be nice to have an example of somewhere where I would want to use a lambda over a list comprehension.

  14. What is difference between map and lambda. Where can we exactly use all those map, lambda and filter. Great 👍 video

  15. I"ve seen many videos about this topic, but this is, BY FAR, the BEST. Not only the pace was the adecuate fir beginners like me, but it was also full of examples and alternatives. Thanks for publishing this video. Thumbs up thumbs ☝!!

  16. That is awesome. simple, neat visually presented.. easily understandable on comparing to traditional functions

  17. that was a real help joe

  18. (5:00) is there really a need for using map with the square function? square takes a list, wouldnt print(square(n)) do the job? good video btw, thanks

  19. Thanks, u explained elegantly.

  20. there are syntax problems in the code shown 4:59. it should be print(square([4,3,2,1])). It should be print(map(square,n))

Leave a Reply

Your email address will not be published. Required fields are marked *