Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 3 of 3 for Example_rand (0.21 sec)

  1. src/math/rand/example_test.go

    	}
    	fmt.Println("Magic 8-Ball says:", answers[rand.Intn(len(answers))])
    }
    
    // This example shows the use of each of the methods on a *Rand.
    // The use of the global functions is the same, without the receiver.
    func Example_rand() {
    	// Create and seed the generator.
    	// Typically a non-fixed seed should be used, such as time.Now().UnixNano().
    	// Using a fixed seed will produce the same output on every run.
    	r := rand.New(rand.NewSource(99))
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Oct 26 16:24:57 UTC 2022
    - 4.2K bytes
    - Viewed (0)
  2. src/math/rand/v2/example_test.go

    	}
    	fmt.Println("Magic 8-Ball says:", answers[rand.IntN(len(answers))])
    }
    
    // This example shows the use of each of the methods on a *Rand.
    // The use of the global functions is the same, without the receiver.
    func Example_rand() {
    	// Create and seed the generator.
    	// Typically a non-fixed seed should be used, such as Uint64(), Uint64().
    	// Using a fixed seed will produce the same output on every run.
    	r := rand.New(rand.NewPCG(1, 2))
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Mon Oct 30 17:09:26 UTC 2023
    - 4.4K bytes
    - Viewed (0)
  3. src/math/rand/v2/regress_test.go

    	defer func() {
    		os.Stdout = oldStdout
    	}()
    
    	r, w, err := os.Pipe()
    	if err != nil {
    		t.Fatal(err)
    	}
    	defer r.Close()
    	defer w.Close()
    
    	go func() {
    		os.Stdout = w
    		Example_rand()
    		os.Stdout = oldStdout
    		w.Close()
    	}()
    	out, err := io.ReadAll(r)
    	if err != nil {
    		t.Fatal(err)
    	}
    
    	var buf bytes.Buffer
    	fmt.Fprintf(&buf, "\t// Output:\n")
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Tue May 07 18:03:11 UTC 2024
    - 20.3K bytes
    - Viewed (0)
Back to top