Hoon101/week5/morse.hoon
2019-08-12 13:31:37 +12:00

65 lines
1.3 KiB
Plaintext

:: the comment ":: code belongs here" indicates that one or more lines of code are needed to make this section of the program work.
|= raw=tape
=<
=. raw (cuss raw)
(convert raw)
|%
:: the latest and greatest rapper
++ mcelem
|= l=@t
?|
&((gte l 'A') (lte l 'Z'))
&((gte l '0') (lte l '9'))
==
++ convert
|= m=tape
^- tape
%- zing
%+ turn m
|= l=@t
?: =(l ' ')
"[_]"
?: (mcelem l)
~[' ' (~(got by table) l) ' ']
~['[' l ']']
++ table
%- my
:~ :- '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' '----.'
==
--