Skip to content

Add permute to standard library #1013

Closed

Description

@jdm

It's too much effort to create a branch and pull request at this point, so I'll paste the code I've been using inline:

iter permute(elts: [@T]) -> [@T] {
    if vec::is_not_empty(elts) {
        for each i in uint::range(0u, vec::len(elts)) {
            let rest = vec::slice(elts, 0u, i);
            rest += vec::slice(elts, i + 1u, vec::len(elts));
            for each permutation in permute(tmp) {
                put [elts[i]] + permutation;
            }
        }        
    } else {
        put [];
    }
}

Activity

  1. mbrubeck commented on Nov 3, 2011

    @mbrubeck
    Contributor

    This issue can be closed; it is fixed by #1121.

  2. jdm commented on Nov 3, 2011

    @jdm
    ContributorAuthor

    .

  3. added a commit that references this issue on Apr 10, 2015
  4. added a commit that references this issue on Dec 17, 2021
    3c8f90b
  5. added a commit that references this issue on Mar 7, 2023
  6. added a commit that references this issue on Aug 21, 2026
  7. added a commit that references this issue on Oct 24, 2026
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

    E-easyCall for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions