How to resolve the algorithm Morse code step by step in the Raku programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Morse code step by step in the Raku programming language

Table of Contents

Problem Statement

Morse code is one of the simplest and most versatile methods of telecommunication in existence. It has been in use for more than 175 years — longer than any other electronic encoding system.

Send a string as audible Morse code to an audio device   (e.g., the PC speaker).

As the standard Morse code does not contain all possible characters, you may either ignore unknown characters in the file, or indicate them somehow   (e.g. with a different pitch).

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Morse code step by step in the Raku programming language

Source code in the raku programming language

my %m = ' ', '_ _ ',
|<
    !	---.
    "	.-..-.
    $	...-..-
    '	.----.
    (	-.--.
    )	-.--.-
    +	.-.-.
    ,	--..--
    -	-....-
    .	.-.-.-
    /	-..-.
    :	---...
    ;	-.-.-.
    =	-...-
    ?	..--..
    @	.--.-.
    [	-.--.
    ]	-.--.-
    _	..--.-
    0	-----
    1	.----
    2	..---
    3	...--
    4	....-
    5	.....
    6	-....
    7	--...
    8	---..
    9	----.
    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	--..
>.map: -> $c, $m is copy {
    $m.=subst(rx/'-'/, 'BGAAACK!!! ', :g);
    $m.=subst(rx/'.'/, 'buck ', :g);
    $c => $m ~ '_';
}

say prompt("Gimme a string: ").uc.comb.map: { %m{$_} // " " }


  

You may also check:How to resolve the algorithm Solve the no connection puzzle step by step in the 11l programming language
You may also check:How to resolve the algorithm Polymorphism step by step in the jq programming language
You may also check:How to resolve the algorithm Quine step by step in the D programming language
You may also check:How to resolve the algorithm Averages/Arithmetic mean step by step in the Octave programming language
You may also check:How to resolve the algorithm Partition an integer x into n primes step by step in the Sidef programming language