portable pseudo-random number generators for Clojure and ClojureScript DEPRECATED
HTML JavaScript Clojure
Latest commit a1b9f2d Sep 17, 2015 @cemerick DEPRECATED


pprng Travis CI status


I don't think anyone is actually using this, but just in case: if you need a common Clojure/ClojureScript API for random number generation, you should use the splittable PRNG implemented for test.check (clojure.test.check.random). I implemented pprng solely to enable double-check, and its deprecation leaves this project without purpose.

portable pseudo-random number generators for Clojure/ClojureScript


Add to your Leiningen project.clj:

[com.cemerick/pprng "0.0.3"]


NOTE pprng does not use cryptographically-secure random number generators, either on Clojure/JVM or ClojureScript/JS. DO NOT use this library to help implement or inform any cryptographically-sensitive algorithm.

user=> (require '[cemerick.pprng :as rng])
;; get a new RNG, optionally providing a seed
user=> (def rng (rng/rng))
;; obtain values from it...
user=> (rng/int rng)
user=> (rng/int rng 1000)
user=> (rng/boolean rng)
user=> (rng/double rng)
;; obtain the seed that was used to create it originally, if necessary
user=> (rng/seed rng)

Need Help?

Ping cemerick on freenode irc or twitter if you have questions or would like to contribute patches.


Copyright ©2013-* Chas Emerick and other contributors.

Distributed under the Eclipse Public License, the same as Clojure. Please see the epl-v10.html file at the top level of this repo.