-
Notifications
You must be signed in to change notification settings - Fork 1
/
transliterate.lisp
54 lines (49 loc) · 1.29 KB
/
transliterate.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
(defpackage :transliterate
(:use :cl-user :cl)
(:export :transliterate))
(in-package :transliterate)
(defun transliterate (str)
(let ((correspondence
'((#\а . "a")
(#\б . "b")
(#\в . "v")
(#\г . "g")
(#\д . "d")
(#\е . "e")
(#\ё . "yo")
(#\ж . "g")
(#\з . "z")
(#\и . "i")
(#\й . "y")
(#\к . "k")
(#\л . "l")
(#\м . "m")
(#\н . "n")
(#\о . "o")
(#\п . "p")
(#\р . "r")
(#\с . "s")
(#\т . "t")
(#\у . "u")
(#\ф . "f")
(#\х . "kh")
(#\ц . "ts")
(#\ч . "ch")
(#\ш . "sh")
(#\щ . "shch")
(#\ь . "")
(#\ы . "i")
(#\ъ . "")
(#\э . "a")
(#\ю . "u")
(#\я . "ya")
(#\SPACE . ".")
(#\COMMA . ".")
(#\! . ".")
(#\? . "."))))
(with-output-to-string (out)
(loop for c across str do
(let ((change (assoc c correspondence)))
(if change
(write-string (cdr change) out)
(write-char c out)))))))