Skip to content

Instantly share code, notes, and snippets.

@leppaott
Created August 27, 2018 18:14
Show Gist options
  • Save leppaott/1f689a427a79c47d16b3c9d915c5e605 to your computer and use it in GitHub Desktop.
Save leppaott/1f689a427a79c47d16b3c9d915c5e605 to your computer and use it in GitHub Desktop.
Generate random names in format of {consonant vowel{1,2}}+
(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