The problem: Morse. Convert a short phrase to Morse Code
The solution:
Note: You can cut and paste these code fragments into the code pane of the Glee interpreter and experiment as you go along to see the actual operations live.
The Glee code:
"
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--..;
@.--.-.; .._._._; ?..--..; ,--..--;
1.----; 2..---; 3...--; 4....-; 5.....;
6-....; 7--...; 8---..; 9----.; 0-----;
"=>raw;
raw~(9 10 13 32 #asc)\|~';'@& ([.x]{(x<-)(x<-_1)})%\% =>tbl;
'Where have all the flowers gone?'%\ =>msg;
'(',|msg,|')',|(tbl[2]<[tbl[1]<** @== `msg=>i])\(i*=0)%\% %*8
,,$;
The Output:
(w).-- (h)....
(a).- (t)- (f)..-. (g)--.
(h).... (a).- (l).-.. (h).... (l).-..
(o)---
(e). (v)...- (l).-..
(e). (o)--- (n)-.
(r).-. (e). (
) ( )
(w).-- (e).
(e). (
)
(e). (?)..--.
(
)
(r).-.
(s)...
( )
The play-by-play:
This completes the example. To better understand these operators and other things you can do with them, consult the operator pages according to the type of data you see being operated on.