Functions { public static <T> Function<List<T>, List<T>> permutationOfList( int... indexes) { return list -> { List<T> result = new ArrayList<>(indexes.length); for (int index : indexes) { result.add(list.get(index < 0 ? list.size() + index : index)); } return result; }; } private  Functions(); static Function<List<T>, T> firstOfList(); static Function<List<T>, T> lastOfList(); static Function<List<T>, T> nthOfList(int index); static Function<List<T>, List<T>> permutationOfList(
      int... indexes); static Function<List<T>, List<T>> withoutSeparators(); static Function<Object, T> constant(T output);  }
@Test public void testPermutationOfList() { assertEquals(EMPTY, permutationOfList().apply(EMPTY)); assertEquals(EMPTY, permutationOfList().apply(THREE)); assertEquals(asList('c', 'a'), permutationOfList(-1, 0).apply(THREE)); assertEquals(asList('a', 'a'), permutationOfList(-3, 0).apply(THREE)); }