Logo

Programming-Idioms

History of Idiom 69 > diff from v11 to v12

Edit summary for version 12 by :

Version 11

2015-08-21, 23:34:42

Version 12

2015-08-21, 23:34:59

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
rand.Seed(s)
Code
rand.Seed(s)
Comments bubble
s is of type int64.
This initializes the default Source.
Comments bubble
s is of type int64.
This initializes the default Source.
Doc URL
https://golang.org/pkg/math/rand/#Seed
Origin
https://golang.org/pkg/math/rand/#Seed
Demo URL
http://play.golang.org/p/CGvwz2uK1o
Demo URL
http://play.golang.org/p/CGvwz2uK1o