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

Modify permutations function to take a size argument #12863

Closed
kmsquire opened this issue Aug 29, 2015 · 13 comments
Closed

Modify permutations function to take a size argument #12863

kmsquire opened this issue Aug 29, 2015 · 13 comments
Labels
good first issue Indicates a good issue for first-time contributors to Julia status:help wanted Indicates that a maintainer wants help on an issue or pull request

Comments

@kmsquire
Copy link
Member

As seen here:

In Python, you can use itertools to generate permutations like so:

>>> list(itertools.permutations("ABC", 2))
 [('A', 'B'), ('A', 'C'), ('B', 'A'), ('B', 'C'), ('C', 'A'), ('C', 'B')]
 Julia has a similar permutations function, but it only accepts one argument.

It woulds be a reasonable extension of the permutations function to add this.

@kmsquire kmsquire added status:help wanted Indicates that a maintainer wants help on an issue or pull request good first issue Indicates a good issue for first-time contributors to Julia labels Aug 29, 2015
@IainNZ
Copy link
Member

IainNZ commented Aug 29, 2015

Why is it reasonable?

@kmsquire
Copy link
Member Author

This functionality is something that at least I have used in the past (in Python), and it should be a fairly straightforward extension to the existing functionality.

Why wouldn't it be reasonable? I'm open to counter arguments.

@kmsquire
Copy link
Member Author

I do also think that the permutations function should probably be moved out of Base (assuming it isn't used, of course).

@IainNZ
Copy link
Member

IainNZ commented Aug 29, 2015

It just seems like one more thing to add for the sake of it, when it should really be in a package (or you can do what I proposed on SO).

@IainNZ
Copy link
Member

IainNZ commented Aug 29, 2015

I don't have strong feelings either way to be honest, but I do lean towards not adding it to Base. Certainly think it should be questioned.

@kmsquire
Copy link
Member Author

(or you can do what I proposed on SO)

Sure.

julia> collect(chain([permutations(x) for x in subsets(collect("ABC"), 2)]...))
6-element Array{Array{Char,1},1}:
 ['A','B']
 ['B','A']
 ['A','C']
 ['C','A']
 ['B','C']
 ['C','B']

I think that would take a little while for most users to figure out if they aren't familiar with the Iterators.jl package. And I find it rather ugly.

(But I really would have no problem if the functionality suggested here were added there instead.)

@kmsquire
Copy link
Member Author

(But if it's put in Iterators.jl, I think it would make sense to move the current permutations function at the same time.)

@mschauer
Copy link
Contributor

Please, permutations certainly belong to base. As a data point: permute is one of the selected primitives in J, http:https://www.jsoftware.com/help/dictionary/vocabul.htm

@AnishShah
Copy link

Hi. If anybody else is not working on this, then can I work on this?

@malmaud
Copy link
Contributor

malmaud commented Oct 11, 2015

@AnishShah You sure can - it would be appreciated.

@catchmrbharath
Copy link

@AnishShah Are you still working on this?

@rawls238
Copy link
Contributor

rawls238 commented Dec 5, 2015

can probably close this since this has been moved out of Base?

@tkelman
Copy link
Contributor

tkelman commented Dec 5, 2015

Yep, good call, closed by #13897. Could be reopened as a feature request at Combinatorics.jl though.

@tkelman tkelman closed this as completed Dec 5, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Indicates a good issue for first-time contributors to Julia status:help wanted Indicates that a maintainer wants help on an issue or pull request
Projects
None yet
Development

No branches or pull requests

8 participants