anchor.diff:  
     public static void main(String...args) {
   
  -    StringGrouper grouper = new StringGrouper(10);
  -
  -    List<String> words = Arrays.asList("123", "456", "789", "abc", "def");
  +    StringGrouper grouper = new StringGrouper(20);
  +
  +    List<String> words = Arrays.asList("Once", "upon", "a", "time", "there", "was", "a", "prince","who", "lived", "in", "a", "magnificent", "castle");
   
       grouper.group().apply(words).forEach(System.out::println);
     }
  
positive.code: 
  == Conclusion
  
  Writing the Grouper class may seem intimidating, but this is "simply" Java 8. No tricks. It would be much simpler with a good functional library as the one I describe in my book link:https://www.manning.com/books/functional-programming-in-java[Functional Programming in Java], to be published thiis summer by Manning, and already available in Manning Early Access Program (MEAP). I also explain all the functional techniques that are put to work and can as well be used with standard Java 8 functional constructs (Function(s), Stream, Optional...)
  
negative.code: }
  ----
  
  Note that the `StringGrouper.group()` method returns a partially applied function. The `identity`, `f` and `p` parameters have been applied, leaving us with a function from `List<String>` to `List<List<String>>`. This makes sense, since we will probably have to process many lists with the same configuration.
  
  Now, the client code is awfully simple:
  
  