ClojureDocs

Nav

Namespaces

rand

clojure.core

Available since 1.0 (source)
  • (rand)
  • (rand n)
Returns a random floating point number between 0 (inclusive) and
n (default 1) (exclusive).
2 Examples
;; Test `rand` never returns `n`:
user=> (some (partial <= 10) (take 100000 (repeatedly (fn [] (int (rand 10))))))
nil
user=> (rand)
0.17469201779243182

user=> (rand 100)
49.542391492950834
See Also

Returns a random integer between 0 (inclusive) and n (exclusive).

Added by alimoeeny

Return a random element of the (sequential) collection. Will have the same performance characteris...

Added by Havvy

Return a random permutation of coll

Added by timgilbert
0 Notes
No notes for rand