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

Published on 12 May 2024 09:40 PM
#Ol

How to resolve the algorithm Morse code step by step in the Ol 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 Ol programming language

Source code in the ol programming language

(display "Please, enter the string in lower case bounded by \" sign: ")
(lfor
   (list->ff '(
     (#\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 . "-----")
     (#\space . " ") (#\. . "  ")))
  (str-iter (read))
  (lambda (codes char)
     (let ((out (getf codes char)))
        (if out (display out)))
     codes))

; ==> Please, enter the string in lower case bounded by " sign:
; <== "hello world"
; ==> ......-...-..--- .-----.-..-..-..

  

You may also check:How to resolve the algorithm A+B step by step in the FALSE programming language
You may also check:How to resolve the algorithm Wilson primes of order n step by step in the EasyLang programming language
You may also check:How to resolve the algorithm Cheryl's birthday step by step in the Perl programming language
You may also check:How to resolve the algorithm Hello world/Newbie step by step in the Racket programming language
You may also check:How to resolve the algorithm Loops/Break step by step in the ALGOL 60 programming language