public static Map<Integer,Set<Object[]>> createPerArityGroups(Object[] objects,int max){
  Map<Integer,Set<Object[]>> result=new LinkedHashMap<>();
  result.put(0,Collections.singleton(new Object[0]));
  for (int i=1; i <= max; i++) {
    Set<Object[]> newSet=new LinkedHashSet<>();
    for (    Object[] oneSmaller : result.get(i - 1)) {
      for (      Object object : objects) {
        newSet.add(CollectionsExt.addToArray(oneSmaller,object));
      }
    }
    result.put(i,newSet);
  }
  return result;
}

public static Map < Integer , Set < Object [ ] > > createPerArityGroups ( Object [ ] objects , int max ) { Map < Integer , Set < Object [ ] > > result = new LinkedHashMap < > ( ) ; result . put ( 0 , Collections . singleton ( new Object [ 0 ] ) ) ; for ( int i = 1 ; i <= max ; i ++ ) { Set < Object [ ] > newSet = new LinkedHashSet < > ( ) ; for ( Object [ ] oneSmaller : result . get ( i - 1 ) ) { for ( Object object : objects ) { newSet . add ( CollectionsExt . addToArray ( oneSmaller , object ) ) ; } } result . put ( i , newSet ) ; } return result ; }
creates a set of all sequences of length max of objects . the order matters and elements may be repeated . the set is grouped by the number of objects in the array . the result is a map from arities to object sequences . note : this is done with arrays rather than lists because in joe we don ' t want to execute any code of the objects .
