Ad
  • Custom User Avatar

    "array" in the reduce statement is the starting value. If you were summing array elements with the reduce statement this value would (usually) be 0.
    The 'a' equates to "array" so the effect of each iteration is to replace (return) array with the next level down in the array, as you progress through each one of the 'indexes' values.

  • Default User Avatar

    i tried this one on http://pythontutor.com, but that gave me no idea how does it work.
    where does it get arguments "a" and "i"? why it has an 'array' at the end of inner return? what it does?
    documentation and articles gave me no clues about using .reduce() except summing array elements