permutations

fun <T> permutations(vararg items: T): Sequence<List<T>>

Lazily generates every permutation of the given items, as Lists, in an unspecified order. The number of permutations generated is items.size factorial, so this quickly becomes expensive for anything but small inputs.


Same as List.permutations, starting from an Iterable rather than a List.


Same as List.permutations, starting from a Sequence rather than a List.


Lazily generates every permutation of the elements of this list, as Lists, in an unspecified order, via the standard recursive "pick each element as head, permute the rest" algorithm. The number of permutations generated is size factorial (e.g. 720 for a 6-element list), so this quickly becomes expensive for anything but small inputs.