Created
August 27, 2018 18:14
-
-
Save leppaott/1f689a427a79c47d16b3c9d915c5e605 to your computer and use it in GitHub Desktop.
Generate random names in format of {consonant vowel{1,2}}+
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 rand-name [] | |
(let [v [\a \e \i \o \u \y] | |
c [\h \j \k \l \m \n \p \r \s \t \v] | |
get-v #(v (rand-int (count v))) | |
get-c #(c (rand-int (count c)))] | |
(loop [s ""] | |
(let [len (count s) c_char (get-c) v_char (get-v) | |
double-v? (= 1 (rand-int 5))] | |
(if (or (>= len 10) (and (>= len 4) (= 1 (rand-int 2)))) | |
(capitalize s) | |
(recur (str s (get-c) (if double-v? (str v_char v_char) v_char)))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment