On Tue, 9 May 2017 13:29:21 +0100, Stian Soiland-Reyes <st...@apache.org> wrote: > I can only see this "value()" style make sense if there is also a common > interface, perhaps DoubleFunction<Double>? > https://docs.oracle.com/javase/8/docs/api/java/util/function/DoubleFunction.html
DoubleUnaryOperator would be better - double applyDouble(double) - then Gamma can be used like this with a native DoubleStream: double[] numbers = { -2.1, -2.0, -1.99, -1.95, -1.9, -1.8, -1.7, -1.6, -1.5, -1.4, -1.3, -1.2, -1.1, -1.0, -0.9 }; Arrays.stream(numbers).map(new Gamma()) .mapToObj(Double::toString) .forEachOrdered(System.out::println); Or even -- if you permit: DoubleStream d = new Random().doubles().map(new Gamma()); https://docs.oracle.com/javase/8/docs/api/java/util/function/DoubleUnaryOperator.html Not sure I like the function name "applyDouble(x)" though.. We could have a static gamma() method (etc) as well. === One thought (which don't work too well with Streams without helper functions or Gamma::new)): If we are making instances of Gamma, then you could make it extend Number and take the "x" argument in the constructor: Number g = new Gamma(0.4); System.out.println(g.floatValue()); Evaluation of the gamma function can be delayed until the first call on any of the methods. This is the style recommended by Elegant Objects: http://www.yegor256.com/2014/05/05/oop-alternative-to-utility-classes.html .. and would allow us to extend it to complex numbers in the future. -- Stian Soiland-Reyes The University of Manchester http://www.esciencelab.org.uk/ http://orcid.org/0000-0001-9842-9718 --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@commons.apache.org For additional commands, e-mail: dev-h...@commons.apache.org