I know if i use:
double data[][] = new double[n][];
// fill the array
DoubleStream stream = Arrays.stream(data).flatMapToDouble(Arrays::stream);
int max = stream.max().getAsDouble();
DoubleStream stream = Arrays.stream(data).flatMapToDouble(Arrays::stream);
int min = stream.min().getAsDouble();
i will get the minimum and maximum of whatever value the stream has as a double.
However i cant for the life of me figure out how to make it into a "Supplier". since
Supplier<Stream> stream = (Supplier<Stream>) Arrays.stream(data).flatMapToDouble(Arrays::stream);
double max = stream.max().getAsDouble();
double min = stream.min().getAsDouble();
doesn not work, and Supplier<DoubleStream> does not work ether.
i managed to get it to work with
Supplier<DoubleStream> stream = () -> Arrays.stream(t).flatMapToDouble(Arrays::stream);
OptionalDouble max = stream.get().max();
OptionalDouble min = stream.get().min();
but why did the values in the stream become a OptionalDouble?