​Challenging because
FP is not an optimization
FP gets you the better code
public int length(String s) {
return s.size;
}
public bool isEven(int i) {
return i % 2 == 0;
}
public bool isStringLenghtEven(String s) {
int i = length(s);
return isEven(i);
}
public Function<String, Boolean> compose(f1 Function<String, Integer>,
f2 Function<Integer, Boolean>) {
return s -> {
Integer i = f1.call(s);
f2.call(i);
}
}
public Function<A, C> compose(f1 Function<A, B>,
f2 Function<B, C>) {
return s -> {
B i = f1.call(s);
f2.call(i);
}
}