Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Morse-code/Nim/morse-code.nim
Normal file
24
Task/Morse-code/Nim/morse-code.nim
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import os, strutils, tables
|
||||
|
||||
const Morse = {'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': "--..", '0': "-----", '1': ".----", '2': "..---", '3': "...--",
|
||||
'4': "....-", '5': ".....", '6': "-....", '7': "--...", '8': "---..",
|
||||
'9': "----.", '.': ".-.-.-", ',': "--..--", '?': "..--..", '\'': ".----.",
|
||||
'!': "-.-.--", '/': "-..-.", '(': "-.--.", ')': "-.--.-", '&': ".-...",
|
||||
':': "---...", ';': "-.-.-.", '=': "-...-", '+': ".-.-.", '-': "-....-",
|
||||
'_': "..--.-", '"': ".-..-.", '$': "...-..-", '@': ".--.-."}.toTable
|
||||
|
||||
proc morse(s: string): string =
|
||||
var r: seq[string]
|
||||
for c in s:
|
||||
r.add Morse.getOrDefault(c.toUpperAscii, "")
|
||||
result = r.join(" ")
|
||||
|
||||
var m: seq[string]
|
||||
for arg in commandLineParams():
|
||||
m.add morse(arg)
|
||||
echo m.join(" ")
|
||||
Loading…
Add table
Add a link
Reference in a new issue