Skip to content

Instantly share code, notes, and snippets.

@kosh04 kosh04/flippy.lsp
Created Feb 3, 2013

What would you like to do?
英数字を180度回転した文字を表示するプログラムの #newlisp 版
#!/usr/bin/env newlisp
;; See also:
(unless utf8
(throw-error "newlisp cannot use UTF-8 encoding"))
(new Tree 'FlipTable)
'(("A" "\u2200") ("B" "\u15FA") ("C" "\u2183") ("D" "\u15E1") ("E" "\u2203")
("F" "\u2132") ("G" "\u2141") ("H" "\u0048") ("I" "\u0049") ("J" "\u027E")
("K" "\u4E2C") ("L" "\u2142") ("M" "\u0057") ("N" "\u004E") ("O" "\u004F")
("P" "\u0064") ("Q" "\u038C") ("R" "\u1D1A") ("S" "\u0053") ("T" "\u22A5")
("U" "\u2229") ("V" "\u039B") ("W" "\u004D") ("X" "\u0058") ("Y" "\u2144")
("Z" "\u005A")
("a" "\u0250") ("b" "\u0071") ("c" "\u0254") ("d" "\u0070") ("e" "\u0259")
("f" "\u025F") ("g" "\u0253") ("h" "\u0265") ("i" "\u0021") ("j" "\u027E")
("k" "\u029E") ("l" "\u006C") ("m" "\u026F") ("n" "\u0075") ("o" "\u006F")
("p" "\u0064") ("q" "\u0062") ("r" "\u0279") ("s" "\u0073") ("t" "\u0287")
("u" "\u006e") ("v" "\u028C") ("w" "\u028D") ("x" "\u0078") ("y" "\u028E")
("z" "\u007A")
("0" "\u0030") ("1" "\u0031") ("2" "\u0032") ("3" "\u03B5") ("4" "\u071B")
("5" "\u0035") ("6" "\u0039") ("7" "\u004C") ("8" "\u0038") ("9" "\u0036")
("." "\u0209") ("," "\u0027") ("-" "\u002D") (":" "\u003A") (";" "\u061B")
("!" "\u0069") ("?" "\u00BF") ("&" "\u214B")
;; for reverse lookup
(dotree (s FlipTable true)
(FlipTable (eval s) (rest (term s))))
(define (%flip s)
(or (FlipTable s) s))
(define (flip str)
(replace "." str (%flip $it) 0x800))
;; __main__
(while (read-line)
(println (flip (current-line))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.