MathIterators { public static ImmutableIterator<Double> add(Iterator<Double> s, double inc) { return map(s, x -> x + inc); } private  MathIterators(); static Comparator<Double> weakDoubleComparator(double epsilon); static UnaryOperator<Double> increment(Double delta); static UnaryOperator<Double> times(Double factor); static InfiniteIterator<Double> random(); static InfiniteIterator<Double> arithmeticSeries(double start, double delta); static InfiniteIterator<Double> geometricSeries(double start, double factor); static ImmutableIterator<Double> exp(); static ImmutableIterator<Double> sin(); static ImmutableIterator<Double> cos(); static ImmutableIterator<Double> add(Iterator<Double> s, double inc); @SuppressWarnings("unchecked") static Iterator<Double> inc(Iterator<Double> s, double inc); static ImmutableIterator<Double> add(Iterator<Double> s, Iterator<Double> t); static ImmutableIterator<Double> multiply(Iterator<Double> s, double factor); static ImmutableIterator<Double> multiply(Iterator<Double> s, Iterator<Double> t); static ImmutableIterator<Double> square(Iterator<Double> t); static InfiniteIterator<Double> inverse(Iterator<Double> t); static ImmutableIterator<Double> divide(Iterator<Double> s, Iterator<Double> t); static UnaryOperator<Double> polynom(Iterator<Double> t, int dim); static UnaryOperator<Double> polynom(Iterator<Double> t); static Iterator<Double> compose(Iterator<Double> t, Iterator<Double> s, int dim); static Iterator<Double> compose(Iterator<Double> t, Iterator<Double> s);  }
@Test public void testScalarAdd() { Iterator<Double> t = unaryGenerator(0.0, x -> x + 1.0); BinaryOperator<Double> acc = (a, b) -> a + b; double sum = reduce(limit(add(t, 2.0), 10), acc); assertEquals(65.0, sum, 0); }