-
Notifications
You must be signed in to change notification settings - Fork 0
/
morse_to_text.hs
59 lines (58 loc) · 2.54 KB
/
morse_to_text.hs
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
55
56
57
58
59
morseToChar :: [Char] -> Char
morseToChar x
| x == " " = ' ' -- U+0020
| x == "-.-.--" = '!' -- U+0021
| x == ".-..-." = '"' -- U+0022
| x == ".-..." = '&' -- U+0026
| x == ".----." = '\'' -- U+0027
| x == "-.--." = '(' -- U+0028
| x == "-.--.-" = ')' -- U+0029
| x == ".-.-." = '+' -- U+002B
| x == "--..--" = ',' -- U+002C
| x == "-....-" = '-' -- U+002D
| x == ".-.-.-" = '.' -- U+002E
| x == "-..-." = '/' -- U+002F
| x == "-----" = '0' -- U+OO30
| x == ".----" = '1' -- U+0031
| x == "..---" = '2' -- U+0032
| x == "...--" = '3' -- U+0033
| x == "....-" = '4' -- U+0034
| x == "....." = '5' -- U+0035
| x == "-...." = '6' -- U+0036
| x == "--..." = '7' -- U+0037
| x == "---.." = '8' -- U+0038
| x == "----." = '9' -- U+0039
| x == "---..." = ':' -- U+003A
| x == "-...-" = '=' -- U+003D
| x == "..--.." = '?' -- U+003F
| x == ".--.-." = '@' -- U+0040
| x == ".-" = 'A' -- U+0041
| x == "-..." = 'B' -- U+0042
| x == "-.-." = 'C' -- U+0043
| x == "-.." = 'D' -- U+0044
| x == "." = 'E' -- U+0045
| x == "..-." = 'F' -- U+0046
| x == "--." = 'G' -- U+0047
| x == "...." = 'H' -- U+0048
| x == ".." = 'I' -- U+0049
| x == ".---" = 'J' -- U+004A
| x == "-.-" = 'K' -- U+004B
| x == ".-.." = 'L' -- U+004C
| x == "--" = 'M' -- U+004D
| x == "-." = 'N' -- U+004E
| x == "---" = 'O' -- U+004F
| x == ".--." = 'P' -- U+0050
| x == "--.-" = 'Q' -- U+0051
| x == ".-." = 'R' -- U+0052
| x == "..." = 'S' -- U+0053
| x == "-" = 'T' -- U+0054
| x == "..-" = 'U' -- U+0055
| x == "...-" = 'V' -- U+0056
| x == ".--" = 'W' -- U+0057
| x == "-..-" = 'X' -- U+0058
| x == "-.--" = 'Y' -- U+0059
| x == "--.." = 'Z' -- U+005A
| x == "..--.-" = '_' -- U+005F
| otherwise = '#' -- undefined
morseToString :: [[Char]] -> [Char]
morseToString x = map morseToChar x