permutations method
Returns an iterable that consists of iterables, where each iterable is a collection of all the permutations of the elements in this iterable.
Example:
void main() {
final list = [1, 2, 3];
final result = list.permutations();
// Result: [
// [1, 2, 3],
// [2, 1, 3],
// [3, 1, 2],
// [1, 3, 2],
// [2, 3, 1],
// [3, 2, 1],
// ]
}
Implementation
Iterable<Iterable<T>> permutations() {
final tempList = toList();
return _permutationsRecursive(tempList, tempList.length, tempList.length);
}