Created
April 1, 2010 02:21
-
-
Save devn/351235 to your computer and use it in GitHub Desktop.
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
(defn walton [#^String s] | |
(let [count-result (rand-int (count (walton-doc s))) | |
expr (nth (walton-doc s) count-result) | |
code-text (first expr) | |
result-text (second expr) | |
expr-length (map count (map seq expr)) | |
code-length (first expr-length) | |
result-length (second expr-length) | |
truncated-result []] | |
(if (>= code-length 457) | |
(conj truncated-result (apply str (take 457 expr) "...")) | |
(conj truncated-result code-text)) | |
(if (>= result-length 457) | |
(conj truncated-result (apply str (take 457) "...")) | |
(conj truncated-result result-text)) | |
truncated-result)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment