Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-18 Thread Ankit Aggarwal via swift-users
Thank you for working on this! On Sun, Dec 17, 2017 at 11:07 PM, Saagar Jha via swift-users < swift-users@swift.org> wrote: > > Saagar Jha > > On Dec 17, 2017, at 22:24, Nevin Brackett-Rozinsky via swift-users < > swift-users@swift.org> wrote: > > …well that was more complicated than I

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-17 Thread Saagar Jha via swift-users
Saagar Jha > On Dec 17, 2017, at 22:24, Nevin Brackett-Rozinsky via swift-users > wrote: > > …well that was more complicated than I anticipated. > > The “random” function was (Int) -> Int, so when I removed the “IndexDistance > == Int” constraint on “shuffle” I either

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-17 Thread Nevin Brackett-Rozinsky via swift-users
…well that was more complicated than I anticipated. The “random” function was (Int) -> Int, so when I removed the “IndexDistance == Int” constraint on “shuffle” I either had to add several “numericCast” calls or make “random” generic. So I made “random” generic. And also fixed the modulo bias

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-17 Thread Nevin Brackett-Rozinsky via swift-users
On Sun, Dec 17, 2017 at 7:37 PM, Dave Abrahams wrote: > > On Dec 16, 2017, at 4:34 PM, Nevin Brackett-Rozinsky via swift-users < > swift-users@swift.org> wrote: > > public extension MutableCollection where Self: RandomAccessCollection, > IndexDistance == Int { > > >

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-17 Thread Dave Abrahams via swift-users
> On Dec 16, 2017, at 4:34 PM, Nevin Brackett-Rozinsky via swift-users > wrote: > > public extension MutableCollection where Self: RandomAccessCollection, > IndexDistance == Int { > IndexDistance == Int is an over-constraint, FWIW. Adding it is generally a mistake.

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-16 Thread Nevin Brackett-Rozinsky via swift-users
On Sat, Dec 16, 2017 at 7:37 PM, Daniel Dunbar wrote: > Would you like to post a PR to fix these issues? > > - Daniel > All right, I’ve submitted a PR that I think should work, though I’m not too confident in the pre-Swift-4 parts (credit to swiftdoc.org if the code

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-16 Thread Saagar Jha via swift-users
While we’re still looking at the Fisher-Yates shuffle package, I stumbled upon this definition of random(): public let random: (Int) -> Int = { while true { let x =

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-16 Thread Saagar Jha via swift-users
Saagar Jha > On Dec 16, 2017, at 16:34, Nevin Brackett-Rozinsky via swift-users > wrote: > > The example implementation of the Fisher-Yates shuffle found here >

Re: [swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-16 Thread Daniel Dunbar via swift-users
Would you like to post a PR to fix these issues? - Daniel > On Dec 16, 2017, at 4:34 PM, Nevin Brackett-Rozinsky via swift-users > wrote: > > The example implementation of the Fisher-Yates shuffle found here >

[swift-users] Incorrect Fisher-Yates shuffle in example code

2017-12-16 Thread Nevin Brackett-Rozinsky via swift-users
The example implementation of the Fisher-Yates shuffle found here on Apple’s GitHub (and linked from swift.org/package-manager) has some problems. Stripping it down to just the Swift 4