Logo

Programming-Idioms

History of Idiom 69 > diff from v4 to v5

Edit summary for version 5 by :

Version 4

2015-07-28, 22:34:09

Version 5

2015-07-28, 22:34:56

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Idiom #69 Seed random generator

Use seed s to initialize a random generator.

If s is constant, the generator output will be the same each time the program runs. If s is based on the current value of the system clock, the generator output will be different each time.

Imports
import "math/rand"
Imports
import "math/rand"
Code
r := rand.New(rand.NewSource(s))
Code
r := rand.New(rand.NewSource(s))
Comments bubble
s is of type int64. r is of type rand.Rand.
Comments bubble
s is of type int64. r is of type *rand.Rand.
Origin
https://golang.org/pkg/math/rand/#NewSource
Origin
https://golang.org/pkg/math/rand/#NewSource
Demo URL
http://play.golang.org/p/HdmaaV4Rcf
Demo URL
http://play.golang.org/p/HdmaaV4Rcf