You're viewing version 1.2.0 of rand-int. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

rand-int

clojure.core

  • (rand-int n)
Returns a random integer between 0 (inclusive) and n (exclusive).

1 Example top

  • user=> (rand-int 30)
    10
    
    user=> (rand-int 30)
    7
    
    ;compare with 
    user=> (int (rand 30))
    
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:3818 top

(defn rand-int
  "Returns a random integer between 0 (inclusive) and n (exclusive)."
  {:added "1.0"}
  [n] (int (rand n)))
Vars in clojure.core/rand-int: defn int rand

Comments top

No comments for rand-int. Log in to add a comment.