Skip to content

Instantly share code, notes, and snippets.

@bryanwoods
Created December 2, 2015 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bryanwoods/d09c38ea0585c0526c37 to your computer and use it in GitHub Desktop.
Save bryanwoods/d09c38ea0585c0526c37 to your computer and use it in GitHub Desktop.
(use '[clojure.string :only (replace-first)])
(def body (atom (slurp "disintegration.txt")))
(def spaces #{\space \newline})
(defn strip-spaces [s] (remove #(spaces %) s))
(defn random-char [s] (rand-nth (strip-spaces s)))
(defn delete-random-char [s]
(replace-first s (random-char s) \space))
(dotimes [n (.length (apply str (strip-spaces @body)))]
(println (swap! body #(delete-random-char %))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment