RosettaCodeData/Task/Morse-code/Arturo/morse-code.arturo

36 lines
708 B
Plaintext

; set the morse code
code: #[
; letters
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: "--.."
; digits
"0": "-----"
"1": ".----"
"2": "..---"
"3": "...--"
"4": "....-"
"5": "....."
"6": "-...."
"7": "--..."
"8": "---.."
"9": "----."
]
; print an encoded message
str: "hello world 2019"
out: ""
loop split str 'ch [
if not? whitespace? ch -> 'out ++ code\[ch]
'out ++ " "
]
print out