static <T> Array<Array<T>> apply(Array<T> elements, int k) { if (k == 0) { return Array.of(Array.empty()); } else { return elements.zipWithIndex().flatMap( t -> apply(elements.drop(t._2 + 1), (k - 1)).map(c -> c.prepend(t._1)) ); } } }
Array<Tuple2<Type, Integer>> tupleTypes = Array.of(tupleClass.getTypeParameters()) .map(tp -> resolveType(tp, type)) .zipWithIndex((t, i) -> Tuple.of(t, i + 1));
static <T> Array<Array<T>> apply(Array<T> elements, int k) { if (k == 0) { return Array.of(Array.empty()); } else { return elements.zipWithIndex().flatMap( t -> apply(elements.drop(t._2 + 1), (k - 1)).map(c -> c.prepend(t._1)) ); } } }