/cl-morse

Morse support for Common Lisp

Primary LanguageCommon LispMIT LicenseMIT

CL-Morse - morse support for Common Lisp

CL-Morse adds morse support for Common Lisp. I.e. you can actually write all (well, almost all) your code in morse. Show this to your friends and colleagues and say, "Well, can your programming language do this!?" They will totally begin to use Lisp.

Documentation

Examples can be seen in example.lisp.

Morse representation

Dot/dit and dash/dah are represented by dot and hyphen. Characters are separated by a single non-dit-dah character and words are separated by two or more non-dit-dah characters.

When translating to morse for use with code the character delimiter is by default equal-sign because of the greater readability for symbols than having all symbols being surrounded by vertical bars. The default word delimiter is two spaces.

Strings and symbols are of course represented as their respective types.

Numbers and single characters are represented by symbols, numbers beginning with N and characters beginning with C. Thus:

(to-morse 1)
=> N....-=..---

(to-morse #\a)
=> C.-

Reference

Run morse code

(Macro) morse-code &body body => result*
Runs morse code, i.e. translates all symbols and strings from body from morse, returning the result.

(Function) enable-morse-mode &optional morse-word (end-sym ...-.-) => t
Sets first character of morse-word as macro character or, if morse-word starts with #, sets the first and second character as dispatch macro character. The reader macro will translate the next sexp like morse-code.
If morse-word is encountered (the rest of morse-word is converted to upper case and interned; then the macro character can be followed by this symbol to make up the morse-word) sexps will be read until EOF or end-sym is encountered.
The default end-sym is the "end of work" morse code.
The readtable is saved for disable-morse-mode at the first call; thus, multiple macro characters can be set.
If morse-word is nil it will be treated as if enable-morse-mode was called with two times with "MORSE" and "morse" respectively.

(Function) disable-morse-mode => ...
Sets the readtable to the value before enable-morse-mode was called for the first time.

Convert to morse

(Generic function) to-morse x &optional (char-delim #= word-delim-str " ") => object
Translates x into morse understood by parse-morse with characters delimited by char-delim and words delimited by word-delim-str. All implementations are defined with the specified defaults. Unimplemented types and objects with unsupported characters returns nil.

(Function) string->morse str &optional (word-delim-n 2) => string
Convenience function. Translates string str to morse with characters delimited by space and words delimited by word-delim-n spaces.

(Macro) morsify-with (char-delim &optional (word-delim-str " ")) &body body => result*
Translates body to morse using char-delim as character delimiter and word-delim-str as word delimiter.
If body is longer than one sexp multiple values are returned. The macro is thus intended for copy-pasting from the REPL.

(Macro) morsify &body body => result*
Calls morsify-with with the default character and word delimiters.

Parse morse

Function parse-morse m => object
Translates m from morse.

Function morse->string str => string
Convenience function. Translates str from morse without type checking.

CL-Morse testimonies

All these testimonies are totally what these people said.

If this had been around in the nineties Common Lisp would totally have been the duct tape that held the Internet together, except of course that it wouldn't be duct tape, just some pleasant sticky stuff!
(Andrew Leonard)

It would not be far from the truth to say that a hacker about to write a program decides what language to use, at least subconsciously, based on the total number of different characters he'll have to type. I will totally redefine Arc based on morse!
(Paul Graham)

I will totally begin to use Lisp!
(My wife, and she's totally a programmer)

I will totally begin to let you use Lisp at work!
(My boss)

I have always had a feeling that my lifetime was limited by the number of unique characters I typed on my keyboard. Being able to write all my code almost entirely using dot and dash has totally reduced my fear of an early death.
(Søren Kierkegaard)