Created
June 23, 2014 02:52
-
-
Save kriyative/54cc3bd55d231983247c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn uuid [] | |
"Return an RFC1422 ver.4 compliant UUID" | |
(let [format "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx" | |
hex "0123456789abcdef" | |
gen #(case % | |
\x (get hex (rand-int 16)) | |
\y (get hex (bit-or 0x8 (bit-and 0x3 (rand-int 16)))) | |
%)] | |
(apply str (map gen format)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment