code: public static <T> Iterator<List<T>> eachPermutation(Iterable<T> self, Closure closure) {
          Iterator<List<T>> generator = new PermutationGenerator<T>(self);
          while (generator.hasNext()) {
              closure.call(generator.next());
          }
          return generator;
      }
docs: Iterates over all permutations of a collection, running a closure for each iteration.
  <p>
  Example usage:
  <pre class="groovyTestCase">def permutations = []
  [1, 2, 3].eachPermutation{ permutations &lt;&lt; it }
  assert permutations == [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 1, 2], [3, 2, 1]]</pre>
  
  @param self the Collection of items
  @param closure the closure to call for each permutation
  @return the permutations from the list
  @since 1.7.0