Skip to content

Instantly share code, notes, and snippets.

@JaHIY
Last active December 23, 2015 04:01
Show Gist options
  • Save JaHIY/2a60f1324f4312effb3c to your computer and use it in GitHub Desktop.
Save JaHIY/2a60f1324f4312effb3c to your computer and use it in GitHub Desktop.
Morse code translator in 1 line of perl6.
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 }
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