Re: [swift-users] Sampling collections

2016-04-10 Thread Milos Rankovic via swift-users
> On 11 Apr 2016, at 02:57, Jens Alfke wrote: > > Welcome to the world of bike-shedding. Love that :) milos___ swift-users mailing list swift-users@swift.org https://lists.swift.org/mailman/listinfo/swift-users

Re: [swift-users] Sampling collections

2016-04-10 Thread Milos Rankovic via swift-users
Thanks, Jacob, for the links. Apple did take steps in this direction by spoiling us with a choice of random sources in the GameplayKit. I’m sure that after that initial effort, the GameplayKit team will continue to bring more power to the randomisation part of the framework. Only, that is not

Re: [swift-users] Sampling collections

2016-04-10 Thread Jens Alfke via swift-users
Well, write up a proposal and submit it to swift-evolution and let people discuss it. > I’m sorry we are spending so much time discussing why this may be difficult > for *someone* (because it likely won’t be us) to implement. We

Re: [swift-users] Sampling collections

2016-04-10 Thread Milos Rankovic via swift-users
> On 11 Apr 2016, at 02:17, Jens Alfke wrote: > > I’d argue that “random” is a broad concept with several possible > implementations. Which RNG does `sample` use? Pick a cryptographic one and it > might be too slow for some use cases; pick a fast one and it'd be > insufficiently random, makin

Re: [swift-users] Sampling collections

2016-04-10 Thread Jacob Bandes-Storch via swift-users
I encourage anyone thinking about PRNG APIs to check out what C++ STL has to offer: http://en.cppreference.com/w/cpp/numeric/random And this analysis/extension of it: http://www.pcg-random.org/posts/ease-of-use-without-loss-of-power.html Jacob On Sun, Apr 10, 2016 at 6:40 PM, Brent Royal-Gordon

Re: [swift-users] Sampling collections

2016-04-10 Thread Brent Royal-Gordon via swift-users
> import Foundation > > (1..<4).sample > [1,2,3].sample > "abc".characters.sample > ["a": 1, "b": 2, "c": 3].sample > > Like so many users of Swift, I have extensions of IntegerType, ClosedInterval > and CollectionType that avail me of the above methods and their family,

Re: [swift-users] Sampling collections

2016-04-10 Thread Jens Alfke via swift-users
> On Apr 10, 2016, at 6:01 PM, Milos Rankovic > wrote: > > As I already stressed, I certainly do not imagine this to be > “Swift-specific”, nor do I see any reason it would need to be. It sounds like you’re asking for a `sample` property to be added to NSArray, NSDictionary, NSSet, etc. You

Re: [swift-users] Sampling collections

2016-04-10 Thread Milos Rankovic via swift-users
> On 10 Apr 2016, at 23:12, Jens Alfke wrote: > You can easily implement your own `sample` property. The very first email of this thread has a link to my example implementation. Here it is again if you mist it: http://stackoverflow.com/a/30285125/1409907

Re: [swift-users] Sampling collections

2016-04-10 Thread Jens Alfke via swift-users
> On Apr 10, 2016, at 4:36 PM, Dave Yost wrote: > > Every package that wraps C functions should be accompanied by a higher-level > package that wraps the raw interface in best Swift fashion, IMO. > A C package without higher-level Swift wrappers is an invitation to chaos as > a zillion people

Re: [swift-users] Sampling collections

2016-04-10 Thread Dave Yost via swift-users
Every package that wraps C functions should be accompanied by a higher-level package that wraps the raw interface in best Swift fashion, IMO. A C package without higher-level Swift wrappers is an invitation to chaos as a zillion people publish competing higher-level wrappers. > On 2016-04-10,

Re: [swift-users] Sampling collections

2016-04-10 Thread Jens Alfke via swift-users
> On Apr 10, 2016, at 1:00 PM, Milos Rankovic > wrote: > > The ObjC–Swift bridge is relevant here only in the sense that I would also > like sampling methods added to `NSArray`, `NSSet` or `NSDictionary`… Any library or program can add methods to any class using extensions. You can easily im

Re: [swift-users] Sampling collections

2016-04-10 Thread Milos Rankovic via swift-users
> On 10 Apr 2016, at 22:16, Erica Sadun wrote: > > I don't think general random sources are a good fit for core functionality I’m sorry, Erica, I still do not understand how your comments about “core functionality” reflect on my original question – have you seen it? Certainly, there is plenty

Re: [swift-users] Sampling collections

2016-04-10 Thread Erica Sadun via swift-users
> On Apr 10, 2016, at 2:39 PM, Milos Rankovic > wrote: > >> On 10 Apr 2016, at 21:23, Erica Sadun > > wrote: >> >> I do not think it's the role of a core language to worry about things like >> distributions, bias, and sampling. > > Why do you mention “the role of

Re: [swift-users] Sampling collections

2016-04-10 Thread Milos Rankovic via swift-users
> On 10 Apr 2016, at 21:23, Erica Sadun wrote: > > I do not think it's the role of a core language to worry about things like > distributions, bias, and sampling. Why do you mention “the role of a core language” here? That was explicitly not the ambition of my question. I’m talking about exten

Re: [swift-users] Sampling collections

2016-04-10 Thread Erica Sadun via swift-users
> On Apr 10, 2016, at 2:00 PM, Milos Rankovic via swift-users > wrote: > > Thank you, Jens, for your response. > > I do however disagree with both points you are making. First, you write that > sampling collection elements at random is: > >> a pretty obscure feature > > > But how can this

Re: [swift-users] Sampling collections

2016-04-10 Thread Milos Rankovic via swift-users
Thank you, Jens, for your response. I do however disagree with both points you are making. First, you write that sampling collection elements at random is: > a pretty obscure feature But how can this be? When you teach students how to implement a card playing game in Swift, how do you shuffl

Re: [swift-users] Sampling collections

2016-04-10 Thread Jens Alfke via swift-users
It sounds like you’re suggesting that a “sample” property (that returns a randomly chosen element) should be added to the standard library? You could suggest that on the swift-evolution list, though IMHO it seems like a pretty obscure feature that not many users would need. I don’t understand t