Programming-Idioms

Implementation
Go

Be concise.

Be useful.

All contributions dictatorially edited by webmasters to match personal tastes.

Please do not paste any copyright violating resource.

Please try to avoid dependencies to third-party libraries and frameworks.

Implementation edit is for fixing errors and enhancing with metadata.

Instead of changing the code of the snippet, consider creating another Go implementation.

Other implementations
import java.util.Random;
Random r = new Random(s);
import "math/rand"
r := rand.New(rand.NewSource(s))
srand($s);
#include <stdlib.h>
srand(s);
std.random, std.stdio;
auto s = 8;
auto gen = Random(s);
writeln(gen.front);
var
  SomeInteger: Integer;
  Value: double;
begin
  ...
   //initializes the PRNG's seed with a value depensing on system time
  Randomize; 
  Value := random;
  ...
   //Output will be the same eacht time the program runs
  RandSeed := SomeInteger; 
  Value := random;
...
end.
import "dart:math";	
var r = new Random(s);
r = Random.new(s)
System.Random.mkStdGen s
import random
rand = random.Random(s)
srand($s);
math.randomseed(s)
use rand::{Rng, SeedableRng, rngs::StdRng};
let mut rng = StdRng::from_seed(s);
const seed = require ('seedrandom')
seed (s)
r = :rand.uniform(n)
using System;
var random = new Random(s);
call random_seed (put=s)
  call random_seed(size = n)
  allocate(seed(n))
  ! ...
  call random_seed(put=seed)
#include <stdlib.h>
srand(s);