Golang math/rand.Perm() function example

package math/rand

Golang math/rand.Perm() function usage example

 package main

 import (
  "fmt"
  "math/rand"
  "time"
 )

 func main() {
  n := 10
  i := 0
  r := rand.New(rand.NewSource(time.Now().UnixNano()))
  for i < n {
 x := r.Perm(10)
 fmt.Println(x)
 i += 1
  }
 }

Reference :

http://golang.org/pkg/math/rand/#Perm

Advertisement