Created
October 13, 2011 19:07
-
-
Save jamiltron/1285184 to your computer and use it in GitHub Desktop.
num to base 62
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
(def base62-alphabet | |
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ") | |
(defn num->base62 [x] | |
(letfn [(base-conv [curr q] | |
(if (>= 0 q) curr | |
(recur (conj curr (nth base62-alphabet (rem q 62))) (quot q 62))))] | |
(base-conv '() x))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment