ZVON > References > Haskell reference
| Indexes | Syntax | Prelude | Ratio | Complex | Numeric | Ix | Array | List | Maybe | Char | Monad | IO | Directory | System | Time | Locale | CPUTime | >> Random <<

Module: Random
Function: getStdGen
Type: IO StdGen
Description: getStdGen and setStdGen get and set the global random number generator, respectively
Related: mkStdGen, newStdGen, setStdGen

Example 1
Program source: 

import Random 

main = do x <- getStdGen
	  print (next x)
	  print (next x)
	  print (fst (next x))
	  setStdGen (snd (next x))
	  print (next x)
	  x <- getStdGen
	  print (next x)
	  newStdGen
	  print (next x)
	  x <- getStdGen
	  print (next x)

Output: (433334474,763021058 329686584)

Output: (433334474,763021058 329686584)

Output: 433334474

Output: (433334474,763021058 329686584)

Output: (473117066,750799641 277682575)

Output: (473117066,750799641 277682575)

Output: (1349143456,750839655 1549179761)