Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the cl-morse Reference Manual, version 1.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Aug 15 03:50:19 2022 GMT+0.
Next: Systems, Previous: The cl-morse Reference Manual, Up: The cl-morse Reference Manual [Contents][Index]
Morse code translation lib written in Common Lisp.
In version 0.1.0 only letters, spaces and a full stop are supported, more to come. Give me a shout or open an issue if you want to add a new feture to this library, please. Originally this library was created because I was a bit rusty at Common Lisp programming (haven't touched it for years of using Clojure) and to have something to check and try various forms of deployment.
Translates text (ignoring case) to morse code and back. The morse code follows a convention that each letter is ended by a forward slash (e.g. 'a' becomes '.-/'). Space is a single '/' and a full stop is two '//'. Which in effect means that letters are separated by a single slash, word by two slashes and sentences by three. When converting a morse code back to text, some ambiguities can happen. This library interprets '////' as '. ' although it could be interpreted as multiple spaces.
Some languages have specific coding for a group of characters, e.g. in Czech, 'ch' is considered a single letter and has a special morse code. This is not supported now.
If an unknown character or code is found, an error is signalled. A restart is provided to continue with the next character.
If you have quicklisp installed
cd ~/quicklisp/local-projects
git clone https://github.com/em7/cl-morse.git
when you run lisp
(ql:quickload "cl-morse")
(asdf:test-system :cl-morse)
otherwise you can clone the repo wherever ASDF finds it and load it.
Package cl-morse
exports four symbols:
unknown-character
skip-character
string->morse
morse->string
The functions expect a string to convert as a parameter and returns a converted string. A keyword :skip-unknown-chars might be supplied (default nil). If true, skips unknown characters. If false, signals 'unknown-character
when encounters one.
The 'unknown-character
condition defines :report
and has a reader unknown-ch
which returns the character which could not be converted.
see tests/main.lisp
(cl-morse:morse->string ".-/-.../")
> "ab"
(cl-morse:string->morse "ab")
> ".-/-.../"
(cl-morse:string->morse "aěščřb" :skip-unknown-chars t)
> ".-/-.../"
(handler-case (cl-morse:string->morse "aěščřb")
(cl-morse:unknown-character (c) (format t "~a~%" c)))
> Unknown charachter 'ě', could not be converted to morse code.
(handler-bind ((cl-morse:unknown-character
#'(lambda (c)
(format t "~a~%" c)
(invoke-restart 'cl-morse:skip-character))))
(cl-morse:string->morse "aěščřb"))
> Unknown charachter 'ě', could not be converted to morse code.
> Unknown charachter 'š', could not be converted to morse code.
> Unknown charachter 'č', could not be converted to morse code.
> Unknown charachter 'ř', could not be converted to morse code.
>
Next: Modules, Previous: Introduction, Up: The cl-morse Reference Manual [Contents][Index]
The main system appears first, followed by any subsystem dependency.
Next: Files, Previous: Systems, Up: The cl-morse Reference Manual [Contents][Index]
Modules are listed depth-first from the system components tree.
Next: Packages, Previous: Modules, Up: The cl-morse Reference Manual [Contents][Index]
Files are sorted by type and then listed depth-first from the systems components trees.
Next: cl-morse/src/main.lisp, Previous: Lisp, Up: Lisp [Contents][Index]
cl-morse (system).
Previous: cl-morse/cl-morse.asd, Up: Lisp [Contents][Index]
src (module).
Next: Definitions, Previous: Files, Up: The cl-morse Reference Manual [Contents][Index]
Packages are listed by definition order.
Next: Indexes, Previous: Packages, Up: The cl-morse Reference Manual [Contents][Index]
Definitions are sorted by export status, category, package, and then by lexicographic order.
Next: Internals, Previous: Definitions, Up: Definitions [Contents][Index]
Next: Conditions, Previous: Public Interface, Up: Public Interface [Contents][Index]
Converts the string with morse code to string with alpha characters. If :skip-unknown-chars is true,
ignores characters which cannot be converted to a alpha. Otherwise signals
’unknown-character condition with unknown-ch reader to get the unknown character. A restart ’skip-character is provided in case you want to e.g. log the characters but skip them.
Converts the string to a morse code. If :skip-unknown-chars is true,
ignores characters which cannot be converted to a morse code. Otherwise signals
’unknown-character condition with unknown-ch reader to get the unknown character. A restart ’skip-character is provided in case you want to e.g. log the characters but skip them.
Previous: Ordinary functions, Up: Public Interface [Contents][Index]
Is signalled when a character is not known and could not be converted to a morse code representation. The character is accessible through ’unknown-ch reader.
error.
The unknown character itself.
:ch
This slot is read-only.
Previous: Public Interface, Up: Definitions [Contents][Index]
Next: Ordinary functions, Previous: Internals, Up: Internals [Contents][Index]
Hashtable mapping alpha strings to morse code. Not case sensitive.
Hashtable mapping morse code string to alpha.
Next: Generic functions, Previous: Special variables, Up: Internals [Contents][Index]
Converts a single character to a morse code. If character could not be
converted, signals an error ’unknown-character.
Offers a restart ’skip-character which ignores the character and returns
an empty string.
Initializes *alpha->morse* and *morse->alpha* hashtables from values in morselist
Converts one morse code character to alpha character. If character could not be converted, signals an error ’unknown-character. Offers a restart ’skip-character which ignorese the character and returns an empty string.
Returns a list of strings which are morse tokens. The strings are shared with the ‘str‘ parameter. If str cannot be tokenized, returns NULL.
Previous: Ordinary functions, Up: Internals [Contents][Index]
Previous: Definitions, Up: The cl-morse Reference Manual [Contents][Index]
Jump to: | C F G I M S T U |
---|
Jump to: | C F G I M S T U |
---|
Next: Data types, Previous: Functions, Up: Indexes [Contents][Index]
Jump to: | *
C S |
---|
Jump to: | *
C S |
---|
Jump to: | C F M P S U |
---|
Jump to: | C F M P S U |
---|