Skip to content

Instantly share code, notes, and snippets.

@emdeesee
Created January 22, 2013 17:35
Show Gist options
  • Save emdeesee/4596531 to your computer and use it in GitHub Desktop.
Save emdeesee/4596531 to your computer and use it in GitHub Desktop.
Rot13 vs. Clojure
(let [alpha (into #{} (concat (map char (range (int \a) (inc (int \z))))
(map char (range (int \A) (inc (int \Z))))))
rot13-map (zipmap alpha (take 52 (drop 26 (cycle alpha))))]
(defn rot13
"Given an input string, produce the rot 13 version of the string. \"hello\" -> \"uryyb\""
[s] (apply str (map #(get rot13-map % %) s))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment