Mercurial > hg > jslab
annotate src/samer/maths/FunctionOfGenerator.java @ 8:5e3cbbf173aa tip
Reorganise some more
author | samer |
---|---|
date | Fri, 05 Apr 2019 22:41:58 +0100 |
parents | bf79fb79ee13 |
children |
rev | line source |
---|---|
samer@0 | 1 package samer.maths; |
samer@0 | 2 |
samer@0 | 3 public class FunctionOfGenerator implements Generator |
samer@0 | 4 { |
samer@0 | 5 Generator g; |
samer@0 | 6 Function f; |
samer@0 | 7 |
samer@0 | 8 public FunctionOfGenerator(Function f, Generator g) { |
samer@0 | 9 this.f=f; this.g=g; |
samer@0 | 10 } |
samer@0 | 11 |
samer@0 | 12 public double next() { return f.apply(g.next()); } |
samer@0 | 13 public void next(double [] x) { |
samer@0 | 14 g.next(x); |
samer@0 | 15 f.apply(x); |
samer@0 | 16 } |
samer@0 | 17 |
samer@0 | 18 public void dispose() { f.dispose(); g.dispose(); } |
samer@0 | 19 public String toString() { return f.format(g.toString()); } |
samer@0 | 20 } |
samer@0 | 21 |