Skip to content

Add tuple_permutations #1001

@JonathanBrouwer

Description

@JonathanBrouwer

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

Activity

ronnodas

ronnodas commented on Jan 4, 2025

@ronnodas
Contributor

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

JonathanBrouwer

JonathanBrouwer commented on Jan 4, 2025

@JonathanBrouwer
Author

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

ronnodas

ronnodas commented on Jan 6, 2025

@ronnodas
Contributor

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

phimuemue commented on Jan 7, 2025

@phimuemue
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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @phimuemue@JonathanBrouwer@ronnodas

        Issue actions

          Add `tuple_permutations` · Issue #1001 · rust-itertools/itertools