12. Go - RNG
import "math/rand"
rand.Seed(time.Now().UnixNano())
variable := rand.intn(50)
// RNG from 0 to 50
rand.Float64()
// RNG from 0 to 1.0
rand.Intn(max-min) + min
// RNG from min to max
rand.Perm(100)
// RNG shuffled array from 0 to 100
import "math/rand"
rand.Seed(time.Now().UnixNano())
variable := rand.intn(50)
// RNG from 0 to 50
rand.Float64()
// RNG from 0 to 1.0
rand.Intn(max-min) + min
// RNG from min to max
rand.Perm(100)
// RNG shuffled array from 0 to 100
Comments
Post a Comment