Hoon101/101/week5/morse.hoon

65 lines
1.3 KiB
Plaintext
Raw Normal View History

2019-08-07 23:40:11 -04:00
:: 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
=<
2019-08-11 21:31:37 -04:00
=. raw (cuss raw)
(convert raw)
2019-08-07 23:40:11 -04:00
|%
2019-08-11 21:31:37 -04:00
:: the latest and greatest rapper
++ mcelem
|= l=@t
?|
&((gte l 'A') (lte l 'Z'))
&((gte l '0') (lte l '9'))
==
2019-08-07 23:40:11 -04:00
++ convert
2019-08-11 21:31:37 -04:00
|= m=tape
^- tape
%- zing
%+ turn m
|= l=@t
?: =(l ' ')
"[_]"
?: (mcelem l)
~[' ' (~(got by table) l) ' ']
~['[' l ']']
2019-08-07 23:40:11 -04:00
++ 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' '----.'
==
--