Skip to content

koher/swift-lcg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SwiftLCG

SwiftLCG provides LinearCongruentialRandomNumberGenerator, which is an implementation of RandomNumberGenerator using linear congruential generators to produce pseudo-randomized numbers.

var random = LinearCongruentialRandomNumberGenerator(seed: 42)
let x: Int = (1 ... 100).randomElement(using: &random)!
let y: Bool = Bool.random(using: &random)
let z: Double = Double.random(in: 0.0 ..< 1.0, using: &random)

LinearCongruentialRandomNumberGenerator is useful to produce same sequences of pseudo-randomized numbers. LinearCongruentialRandomNumberGenerator instances initialized with same seeds always produce same sequences.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages