Question : left fold java
Answered by : samuel-sayag
# 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; }
Source : | Last Update : Mon, 14 Jun 21
Question : left fold java
Answered by : wicked-whale-fhdf8bsxastr
public static String concatenate(List<Character> chars) { return chars .stream() .reduce(new StringBuilder(), StringBuilder::append, StringBuilder::append).toString(); }
Source : https://nullorempty.org/questions/41240414/Equivalent-of-Scalas-foldLeft-in-Java-8 | Last Update : Tue, 01 Mar 22