Last active
March 19, 2019 14:11
-
-
Save vitorhead/03f6045d655d3bc32a93c67cdf6cece1 to your computer and use it in GitHub Desktop.
An attempt to make a runic translator. As soon as you boot it in your repl, enter (setup) to start and you can type whatever you want to translate. When done, enter "exit" to quit the enviroment. The runes were copied from the URL in the gist. No further research has been done.
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
;https://www.furorteutonicus.eu/germanic/runescribe/index.php | |
(def runes "ᚨᛒᚲᛞᛖᚠᚷᚺᛇᚲᛚᛗᚾᛟᛈᛩᚱᛋᛏᚢᚡᚹᛪᛃᛋᛎ") | |
(def alphabet "abcdefghijklmnopqrstuvwxyz") | |
(def values (zipmap alphabet runes)) | |
(defn is-in? | |
[elem col] | |
(some #(= elem %) col)) | |
(defn translate | |
[s] | |
(cond | |
(is-in? s alphabet) (values s) | |
:else s)) | |
(defn validate | |
[arg] | |
(not= "exit" arg)) | |
(defn setup | |
[] | |
(println "Runic translation!") | |
(loop [lines (repeatedly read-line)] | |
(let [line (first lines)] | |
(when (validate line) | |
(println (map translate (clojure.string/lower-case line))) | |
(recur (next lines)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment