Created
October 5, 2016 18:06
-
-
Save pphetra/50f08008bcc503cd5786118b50a34384 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (ns captcha) | |
| (defrecord Captcha [left op right]) | |
| (defn render-in-text [value] | |
| (nth ["zero" "one" "two" "three" "four" "five" "six" "seven" "eight" "nine"] value)) | |
| (defn render-captcha [captcha pattern] | |
| (let [l (.left captcha) | |
| r (.right captcha)] | |
| (list | |
| (if (= pattern 1) (render-in-text l) (str l)) | |
| (name (.op captcha)) | |
| (if (= pattern 2) (render-in-text r) (str r)) | |
| ))) | |
| (def t1 (Captcha. 1 :+ 4)) | |
| (clojure.string/join " " (render-captcha t1 1)) ;; => "one + 4" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment