left fold java code example
Example: left fold java
# https://apocalisp.wordpress.com/2008/04/22/left-fold-in-java/
# now that there is lambdas in Java it's certainly easier but
# this one should stay with us for it is beautiful!
public static <A, B> A fold(F<A, F<B, A>> f, A z, Iterable<B> xs)
{ A p = z;
for (B x : xs)
{ p = f.f(p).f(x); }
return p; }