λ Tony's Blog λ
Project Euler Problem 1 Functional Java
Posted on October 3, 2008Project Euler Problem 1 using Functional Java:
import static fj.pre.Monoid.intAdditionMonoid;
import static fj.data.List.range;
import fj.F;
...
final int problem1 = intAdditionMonoid.sumLeft(range(0, 1000).filter(new F<Integer, Boolean>() {
public Boolean f(final Integer a) {
return a % 3 == 0 || a % 5 == 0;
} }));