1

Suppose I wish to process 2 List of the same length.

A good example would be vector dot product.

Suppose vector a = [1 2 3], b = [0; 1; 2;], then a .* b = 1*0 + 2*1 + 3*2 = 8

Can I do this with stream?

Mandar Pandit
  • 2,171
  • 5
  • 36
  • 58
Fermat's Little Student
  • 5,549
  • 7
  • 49
  • 70
  • 2
    This operation is called a [convolution/"zip"](http://en.wikipedia.org/wiki/Convolution_(computer_science)) - see http://stackoverflow.com/questions/17640754/zipping-streams-using-jdk8-with-lambda-java-util-stream-streams-zip - and then in the example, is followed by a sum/fold. – user2864740 Jun 13 '14 at 15:28
  • yes, this is a duplicate of 17640754. for some reason my answer was deleted but you can get the code here: http://pastebin.com/R5Sx07HC – Claude Martin Jun 16 '14 at 20:32
  • 1
    Yes, likely duplicate. The short answer is to use `IntStream.range` to drive the stream and to use those values to index into the arrays or lists. – Stuart Marks Jun 21 '14 at 18:46

0 Answers0