-
Couldn't load subscription status.
- Fork 13.9k
Closed
Description
The permutations of [x] should be the list [[x]].
Additionally, I would also expect the permutations of [] to be [[]] (as it is in python, which also matches 0! = 1! = 1).
Currently, the permutations function (std::slice::ImmutableCloneableVector::permutations) returns [] in both cases.
Example code:
fn main(){
let clists = [~[], ~['x'], ~['x','y']];
for clist in clists.iter(){
let perms : Vec<~[char]> = clist.permutations().collect();
println!("Permutations of {}: {}", clist, perms);
}
}Prints out
Permutations of []: []
Permutations of [x]: []
Permutations of [x, y]: [[x, y], [y, x]]
Instead of the expected
Permutations of []: [[]]
Permutations of [x]: [[x]]
Permutations of [x, y]: [[x, y], [y, x]]
Metadata
Metadata
Assignees
Labels
No labels