How to implement a list fold in Java

Posted by Peter Kofler on Stack Overflow See other posts from Stack Overflow or by Peter Kofler
Published on 2009-06-04T13:56:22Z Indexed on 2010/05/21 17:50 UTC
Read the original article Hit count: 219

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

© Stack Overflow or respective owner

Related posts about java

Related posts about collections