roul /

Filename Size Date modified Message
99 B
123 B
48 B
925 B
330 B


Roul (from "roulette") is a tiny Clojure library for working with random numbers more easily.

For example:

(require '[roul.random :as rr])

; Get a random integer between 0 and 10
(rand-int 10)    ; Default Clojure
(rr/rand-int 10) ; Roul

; Get a random integer between 10 and 20
(+ 10 (rand-int 10)) ; Default Clojure
(rr/rand-int 10 20)  ; Roul

; Get a random element from a weighted collection

; Returns coffee roughly 80% of the time, tea 15%, and soda 5%.
(rr/rand-nth-weighted {:coffee 0.80 :tea 0.15 :soda 0.05})

; Returns cats roughly twice as often as boots.
(rr/rand-nth-weighted [[:boots 14] [:cats 28]])


You need Leiningen 2 to use this. Sorry.

[roul "0.2.0"]


Read the documentation.


Copyright © 2012 Steve Losh and Contributors

MIT/X11 Licensed

Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.