Created
January 22, 2013 17:35
-
-
Save emdeesee/4596531 to your computer and use it in GitHub Desktop.
Rot13 vs. Clojure
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
(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