Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8237531

Stream.reduce accumulator argument has to be associative

XMLWordPrintable

      A DESCRIPTION OF THE PROBLEM :
      It's about java.util.stream.Stream.reduce(U identity,BiFunction<U, ? super T, U> accumulator, BinaryOperator<U> combiner) documentation:
      accumulator – an associative, non-interfering, stateless function for incorporating an additional element into a result
      This means: (a op b) op c = a op (b op c).
      The problem is that the above definition requires an BinaryOperator, not only a BiFunction, because (a op b) requires b of type T while (b op c) requires b of type U. If U and T are distinct, this is impossible.




      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: