How to implement a list fold in Java
- by Peter Kofler
I have a List and want to reduce it to a single value (functional programing term "fold", Ruby term "inject"), like
Arrays.asList("a", "b", "c") ... fold ... "a,b,c"
As I am infected with functional programing ideas (Scala), I am looking for an easier/shorter way to code it than
sb = new StringBuilder
for ... {
append ...
}
sb.toString