Skip to content

Instantly share code, notes, and snippets.

@klgraham
Created March 26, 2016 04:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save klgraham/b643026b17d096b669c1 to your computer and use it in GitHub Desktop.
Save klgraham/b643026b17d096b669c1 to your computer and use it in GitHub Desktop.
func nextInt(min min: Int, max: Int) -> ((Void) -> Int) {
assert(max > min)
return { () in return Int(arc4random_uniform(UInt32((max - min) + 1))) + min }
}
let die6 = Distribution<Int>(get: nextInt(min: 1, max: 6))
die6.sample(10)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment