Following obviously works, but I do not like to wrap items in Tuple,
ImmutableMap<String, Function<Tuple2<Double>, Double>> op = new //
ImmutableMap.Builder<String, Function<Tuple2<Double>, Double>>()
.put("+", new Function<Tuple2<Double>, Double>() {
@Override public Double apply(Tuple2<Double> data) {
return data.Val_1 + data.Val_2;
}
}).build();
System.out.println(op.get("+").apply(new Tuple2<Double>(3d, 4d)));
I want to write something like:
ImmutableMap<String, Function<Double[], Double>> op = new //
ImmutableMap.Builder<String, Function<Double[], Double>>()
.put("+", new Function<Double[], Double>() {
@Override
public Double apply(Double... data) {
return data[0] + data[1];
}
}).build();
System.out.println(op.get("+").apply(3d, 4d));
Help would be most useful, ty.
Edit: Problem solved, started using:
public interface T2Function<T> {
T apply(T Val_1, T Val_2);
}