Public Vars

Back

rand-int (clj)

(source)

function

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

Examples

clojure
(ns clojure.test-clojure.reducers
  (:require [clojure.core.reducers :as r]
            [clojure.test.generative :refer (defspec)]
            [clojure.data.generators :as gen])
  (:use clojure.test))

(deftest test-fold-runtime-exception
  (is (thrown? IndexOutOfBoundsException
               (let [test-map-count 1234
                     k-fail (rand-int test-map-count)]
                 (r/fold (fn ([])
                           ([ret [k v]])
                           ([ret k v] (when (= k k-fail)
                                        (throw (IndexOutOfBoundsException.)))))
                         (zipmap (range test-map-count) (repeat :dummy)))))))
clj-kondo/clj-kondo
(ns cond-without-else1
  (:refer-clojure :exclude [cond])
  (:require [clojure.core :as c]))

(def n (rand-int 10))

(ns cond-without-else2)
(def n (rand-int 10))
clj-kondo/clj-kondo
(ns cond-without-else1
  (:refer-clojure :exclude [cond])
  (:require [clojure.core :as c]))

(def n (rand-int 10))

(ns cond-without-else2)
(def n (rand-int 10))
clj-kondo/clj-kondo
(ns cond-without-else1
  (:refer-clojure :exclude [cond])
  (:require [clojure.core :as c]))

(def n (rand-int 10))

(ns cond-without-else2)
(def n (rand-int 10))
typedclojure/typedclojure
(ns ^:no-doc typed.ann.clojure
  "Type annotations for the base Clojure distribution."
  #?(:cljs (:require-macros [typed.ann-macros.clojure :as macros]))
  (:require [clojure.core :as cc]
            [typed.clojure :as t]
            #?(:clj [typed.ann-macros.clojure :as macros])
            #?(:clj typed.ann.clojure.jvm) ;; jvm annotations
            #?(:clj clojure.core.typed))
  #?(:clj
     (:import (clojure.lang PersistentHashSet PersistentList
                            APersistentMap #_IPersistentCollection
                            #_ITransientSet
                            IRef)
              (java.util Comparator Collection))))

cc/rand [(t/? t/Num) :-> t/Num]
cc/rand-int [t/Int :-> t/Int]
cc/ex-info (t/IFn [(t/Nilable t/Str) (t/Map t/Any t/Any) :-> t/ExInfo]
                  [(t/Nilable t/Str) (t/Map t/Any t/Any) (t/? #?(:clj (t/Nilable Throwable) :cljs t/Any)) :-> t/ExInfo])
cc/ex-data (t/IFn [t/ExInfo :-> (t/Map t/Any t/Any)]
                  [t/Any :-> (t/Nilable (t/Map t/Any t/Any))])
cc/ex-message [t/Any :-> (t/Nilable t/Str)]
cc/ex-cause [t/Any :-> #?(:clj (t/Nilable Throwable) :cljs t/Any)]
borkdude/flycheck-clj-kondo
(ns cond-without-else1
  (:refer-clojure :exclude [cond])
  (:require [clojure.core :as c]))

(def n (rand-int 10))

(ns cond-without-else2)
(def n (rand-int 10))