Ad
  • Default User Avatar

    The first call to Lambda Function by std::accumulate uses the initial value 0 as 'a' and the first element of the vector as 'b'.

    for these ex : std::vector{-1, 2, 3, 4, -5};

    first imple : a = 0, b = -1 ==> resul a + std::max(0, b) = 0 + 0 = 0; then store the result to a.

    Second imple : a = 0, b = 2 ==> resul a + std::max(0, b) = 0 + 2 = 2; then store the result to a.
    .....