IntPipelineError in a nested loop

Jose jgetino at telefonica.net
Tue Apr 9 02:21:36 PDT 2013


 

Sorry if this issue has been commented before, but I coudn't find it in the
archives.

Tryng to use IntStream to emulate a nested loop, I get a IntPipelineError.

The code is below:

public interface IntBiConsumer {
    void accept(int n, int m);

    static void fold(IntStream sx, IntStream sy, IntBiConsumer bc) {
        sx.forEach(nx -> sy.forEach(ny -> bc.accept(nx, ny)));
    }

    class Demo {
        public static void main(String[] args) {
            IntStream sx = Streams.intRange(0, 10);
            IntStream sy = Streams.intRange(0, 5);
            IntBiConsumer bc = (x, y) -> System.out.println("x: " + x + ",
y: " + y);
            fold(sx, sy, bc);
        }
    }
}	



More information about the lambda-dev mailing list