Skip to content

Instantly share code, notes, and snippets.

@oranenj oranenj/scratch.clj
Created Oct 20, 2009

What would you like to do?
(def *vowels* (vec "aeiou"))
(def *consonants* (vec "qwrtpsdgfhjklzxcvbnm"))
(defn seq-of-random
"produces a seq of elements from v at random"
(repeatedly #(nth v (rand-int (count v)))))
(defn drop-randomly
"drop elements from sequence at random"
(filter (fn [_] (zero? (rand-int 2))) seq))
(defn random-chars []
"produces an infinite sequence of random characters"
(interleave (seq-of-random *vowels*)
(seq-of-random *consonants*))))
(defn words [n]
"produces an infinite sequence of random 'words' of length n"
(map (partial apply str) (partition n (random-chars))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.