Diagnostic Quiz
Problems
*1-7. Application of Monad Laws
class A {
private final int value;
private final int cumulative;
public A(int value, int cumulative) {
this.value = value;
this.cumulative = cumulative;
}
public static A of(int value) {
return new A(value, 0);
}
public A flatMap(Transformer<Integer, A> transformer) {
A updated = transformer.transform(this.value);
return new A(updated.value, updated.cumulative + this.cumulative);
}
public String toString() {
return this.value + " " + this.cumulative;
}
}*5. What does the following code evaluate to?
8. Parallel and Concurrent Programming
9. Requirements for a stream to be parallelized
*14. More on reduce()
reduce()
15. Requirements for reduce() to be safe to be parallelized
reduce() to be safe to be parallelizedTips
Last updated