About 26,400,000 results
Open links in new tab
  1. python - How does reduce function work? - Stack Overflow

    Feb 2, 2012 · 9 From the Python reduce documentation, reduce (function, sequence) returns a single value constructed by calling the (binary) function on the first two items of the sequence, then on the …

  2. How to use filter, map, and reduce in Python 3 - Stack Overflow

    Nov 30, 2012 · Why are the results different? How can I get Python 3 code to work like the Python 2 code did? See also: What is the problem with reduce ()? for specific motivation for the change to put …

  3. Pra que serve a função `reduce` em Python?

    Apr 17, 2018 · Digo que esse exemplo é didático porque já existe uma função equivalente no Python: a min. Ainda assim, acho que o exemplo é legal pra dar outra ideia do poder de reduce. Além do …

  4. functional programming - Python reduce explanation - Stack Overflow

    Nov 28, 2012 · What reduce does is that it iterates through the iterable. First it sends the first two values to the function. Then it sends the result of that together with the next value, and so on. So in your …

  5. python - What is the 'pythonic' equivalent to the 'fold' function from ...

    In Python you would just do sum([1,2,3,4,5]) and even Haskell purists would generally prefer sum [1,2,3,4,5]. For non-trivial scenarios when there is no obvious convenience function, the idiomatic …

  6. python - What is the problem with reduce ()? - Stack Overflow

    As Guido says in his The fate of reduce () in Python 3000 post: So now reduce (). This is actually the one I've always hated most, because, apart from a few examples involving + or *, almost every time I …

  7. How does lambda function work with reduce function in python?

    Apr 6, 2021 · I think the documentation of functools.reduce (function, iterable [, initializer]) is quite readable. The iteration is carried out, applying the operation from left to right to consecutive elements …

  8. What's the exact usage of __reduce__ in Pickler - Stack Overflow

    Nov 8, 2013 · I know that in order to be picklable, a class has to overwrite __reduce__ method, and it has to return string or tuple. How does this function work? What the exact usage of __reduce__? …

  9. Python reduce to get list of items in a list - Stack Overflow

    I came across this code when I was researching how the reduce() function in Python works. It prints 7, which is the expected output, and returns the total number of items from list1, the same as th...

  10. python - how lambda works with reduce - Stack Overflow

    Aug 4, 2017 · Recall that reduce works by giving it a method that takes 2 arguments, a sequence of objects (in this case, a sequence of functions), and an optional initial value.