Created
May 5, 2013 19:50
-
-
Save Blecki/5521957 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
| (set @globals encoding-table | |
| (record | |
| (mape "abcdefghijklmno") | |
| (base "─│┌┐└┘├┤┬┴┼▲►▼◄") | |
| (a "──┐") | |
| (b "──┘") | |
| (c "──┤") | |
| (d "─┬┐") | |
| (e "─┬┘") | |
| (f "─┬┤") | |
| (g "─┴┐") | |
| (h "─┴┘") | |
| (i "─┴┤") | |
| (j "─┼┐") | |
| (k "─┼┘") | |
| (l "─┼┤") | |
| (m "┬─┐") | |
| (n "┬─┘") | |
| (o "┬─┤") | |
| (p "┬┬┐") | |
| (q "┬┬┘") | |
| (r "┬┬┤") | |
| (s "┬┴┐") | |
| (t "┬┴┘") | |
| (u "┬┴┤") | |
| (v "┬┼┐") | |
| (w "┬┼┘") | |
| (x "┬┼┤") | |
| (y "┴─┐") | |
| (z "┴─┘") | |
| (A "┴─┤") | |
| (B "┴┬┐") | |
| (C "┴┬┘") | |
| (D "┴┬┤") | |
| (E "┴┴┐") | |
| (F "┴┴┘") | |
| (G "┴┴┤") | |
| (H "┴┼┐") | |
| (I "┴┼┘") | |
| (J "┴┼┤") | |
| (K "┼─┐") | |
| (L "┼─┘") | |
| (M "┼─┤") | |
| (N "┼┬┐") | |
| (O "┼┬┘") | |
| (P "┼┬┤") | |
| (Q "┼┴┐") | |
| (R "┼┴┘") | |
| (S "┼┴┤") | |
| (T "┼┼┐") | |
| (U "┼┼┘") | |
| (V "┼┼┤") | |
| ("." "►──") | |
| ("!" "►┼┤") | |
| ("?" "►─┐") | |
| ) | |
| ) | |
| (defun index-of ((arg str)(arg char)) | |
| (fori i 0 (strlen str) | |
| (if (= (strind str i) char) | |
| (break i) | |
| -1 | |
| ) | |
| ) | |
| ) | |
| (defun get-seq ((arg char)) | |
| (@globals.encoding-table.(char)) | |
| ) | |
| (defun is-capital ((arg char)) | |
| (&& (>= char 'A') (<= char 'Z')) | |
| ) | |
| (defun to-lower ((arg char)) | |
| (tochar (+ (- char 'A') 'a')) | |
| ) | |
| (defun transform-last ((arg str)) /* Check the last character of the string and transform it into an extended version. */ | |
| (let ((last (strind str (- (strlen str) 1)))) | |
| (strcat | |
| (substr str 0 (- (strlen str) 1)) | |
| (if (= last '┐') "┬" | |
| (if (= last '┤') "┼" | |
| (if (= last '┘') "┴" | |
| last | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| (defun encode-character ((arg char)(arg space)) | |
| (if (is-capital char) | |
| (strcat | |
| (transform-last (get-seq (to-lower char))) | |
| "◄" | |
| ) | |
| (strcat | |
| (get-seq char) | |
| space | |
| ) | |
| ) | |
| ) | |
| (defun encode-string ((arg str)(arg space)) | |
| (let ( | |
| (prev-space true) | |
| (next-space true) | |
| ) | |
| (strcat | |
| $(mapi i 0 (strlen str) | |
| (let ((cur-char (strind str i))) | |
| (if (= cur-char ' ') | |
| (lastarg | |
| (var prev-space true) | |
| (strcat space space space space space) | |
| ) | |
| (lastarg | |
| (var next-space (|| (= i (- (strlen str) 1)) (= (strind str (+ i 1)) ' '))) | |
| (strcat | |
| ( | |
| (if (&& prev-space next-space) "►" | |
| (if prev-space "┌" | |
| (if next-space "└" "├") | |
| ) | |
| ) | |
| (var prev-space false) | |
| ) | |
| (encode-character cur-char space) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| (defun max ((arg-repeat values)) | |
| (let ((max- (first values))) | |
| (lastarg | |
| (for value values (if (> value max-) (var max- value))) | |
| max- | |
| ) | |
| ) | |
| ) | |
| (print @globals.encoding-table.mape "\n" @globals.encoding-table.base "\n") | |
| (print "\n\n" (encode-string "Hello World!" " ") "\n\n") | |
| (defun encode-paragraph ((arg segments)(arg line-break)(arg space)) | |
| (let ( | |
| (pieces (reverse (map word segments (encode-string word space)))) | |
| ) | |
| (strcat | |
| $(mapi counter 0 (max $(map piece pieces (/ (strlen piece) 5))) | |
| (strcat | |
| $(map piece pieces | |
| (strcat | |
| (if (< (* 5 counter) (strlen piece)) /*Pieces are not all the same lenth.*/ | |
| (let ((bit (substr piece (* 5 counter) 5))) | |
| (if (= bit " ") | |
| (strcat space space space space space space) | |
| (strcat bit space) | |
| ) | |
| ) | |
| (strcat space space space space space space) | |
| ) | |
| ) | |
| ) | |
| line-break | |
| ) | |
| ) | |
| ) | |
| ) | |
| ) | |
| (defun write-to-file ((arg file-name)(arg text)) | |
| (let ((_file (file.open file-name "WRITE") (file.close _file))) | |
| (nop | |
| (file.write _file text) | |
| (print text) | |
| ) | |
| ) | |
| "Create a file containing the text" | |
| ) | |
| (defun encodei ((arg text-items)) | |
| (strcat "[cipher][fixed letter spacing]" (encode-paragraph text-items "[line break]" " ") "[variable letter spacing][normal]") | |
| ) | |
| (defun encode ((arg text-items)) | |
| (unescape (encode-paragraph text-items "\n" " " " ")) | |
| ) | |
| (defun i-text ((arg name)(arg text-items)) | |
| (unescape "The cipher-(name) is some text which varies.\nThe cipher-(name) is \"(encodei text-items)\".\n\n") | |
| ) | |
| (print (encode-paragraph ^("The quick" "brown Fox" "jumps over" "the lazy" "Dog.") "\n" " ")) |
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
| ┌─┬┬◄ ┌┬┴┘ ┌─┼┐ ┌──┘ ┌┬┴┴◄ | |
| ├┬─┤ ├─┴┘ ├┬┴┤ ├┬┬┤ ├─┴┘ | |
| ├─┴┐ └─┬┘ ├┬─┐ ├┬─┤ └─┬┘ | |
| └►── ├┬┬┐ ├┬┼┘ | |
| ┌─┼┤ └┬┴┐ └┬─┘ ┌┬┬┘ | |
| ├──┐ ├┬┴┤ | |
| ├┴─┘ ┌┬─┤ ┌─┬┼◄ ├─┴┤ | |
| └┴─┐ ├┬┼┐ ├┬─┤ ├──┤ | |
| ├─┬┘ └┬┼┤ └─┼┘ | |
| └┬┬┤ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment