Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tuple_permutations #1001

Open
JonathanBrouwer opened this issue Dec 8, 2024 · 4 comments
Open

Add tuple_permutations #1001

JonathanBrouwer opened this issue Dec 8, 2024 · 4 comments

Comments

@JonathanBrouwer
Copy link

There is the combinations() and tuple_combinations() functions, I'm however missing the tuple_permutations() function.

Is there a reason this couldn't exist?
If not, I might even be open to implementing it depending on how much macro hackery is needed

@ronnodas
Copy link
Contributor

ronnodas commented Jan 4, 2025

It may be easier to add array_permutations() if you want to avoid macro hackery.

@JonathanBrouwer
Copy link
Author

That's true and in general probably nicer to use than tuples, thanks for the pointer!

@ronnodas
Copy link
Contributor

ronnodas commented Jan 6, 2025

It seems possible to share most of the code from permutations(), similar to the array_combinations() implementation. In that case we probably want to start with:

impl<T> PoolIndex<T> for Box<[usize]> {
    type Item = Vec<T>;

   ...
}

and then make PermutationState generic. (Aside: I'm not sure why PermutationState::Loaded.indices is a Box<[usize]> instead of a Vec<usize>.)

@phimuemue
Copy link
Member

Aside: I'm not sure why PermutationState::Loaded.indices is a Box<[usize]> instead of a Vec<usize>.

Canonically we use Box<[usize]> if the size stays unchanged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants