[swift-evolution] Permutations

Erica Sadun erica at ericasadun.com
Fri Jun 17 13:29:04 CDT 2016


On Jun 17, 2016, at 10:42 AM, Daryle Walker via swift-evolution <swift-evolution at swift.org> wrote:
> 
> I’ve seen the WWDC 2016 Keynote and State of the Platforms videos.  I haven’t seen any others so I don’t spoil myself before typing my ideas down.  Apologies if this has already been covered.
> 
> I saw that the “PermutationGenerator” type is being retired in Swift 3.  It inspired me to see how I can implement such a type:
> 
> 1. Is the functionality of the existing “PermutationGenerator” being moved to another type?
> 2. Would my type be suitable to add to the standard library?  Would the name need to be changed?  (The name is appropriate, but it’s just one letter different from a depreciated type.)

If they were writing Swift from scratch today, it would not be on my personal list of types Swift should add in the standard library. 

Permuting a collection's indices isn't that typical a task, and when it does apply I think there are better ways to do this than a dedicated stdlib type. It's easy to add shuffling and take by-n or take m copies with just a few lines of code that don't generalize well. There's also GameplayKit support for Cocoa/touch devs that work well w/ the new indexing model. 

I know there's also been interest in striding over collections, not sure where that stands right now.

-- E


More information about the swift-evolution mailing list