Last active
December 23, 2015 04:01
-
-
Save JaHIY/2a60f1324f4312effb3c to your computer and use it in GitHub Desktop.
Morse code translator in 1 line of perl6.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my %h = <.--.-. @ ...-..- $ .-..-. " ..--.- _ -....- - .-.-. + -...- = -.-.-. ; ---... : ----- 0 ----. 9 ---.. 8 --... 7 -.... 6 ..... 5 ....- 4 ...-- 3 ..--- 2 .---- 1 .--.-. @ -..-. / ..--.. ? --..-- , .-.-.- . --.. Z -.-- Y -..- X .-- W ...- V ..- U - T ... S .-. R --.- Q .--. P --- O -. N -- M .-.. L -.- K .--- J .. I .... H --. G ..-. F . E -.. D -.-. C -... B .- A>; for lines() { say .split(/<space>/).map({ %h{$_} // $_ }).join } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
my %h = <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 ----- : ---... ; -.-.-. = -...- + .-.-. - -....- _ ..--.- " .-..-. $ ...-..- @ .--.-.>; for lines() { say .split("", :skip-empty).map({ %h{.uc} // "-" }).join(" ") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment