Exercise 1.2.5

More Characters

While not portable, and not part of the Common Lisp standard, in SBCL and a few other Lisp implementations, you can refer to any character beyond the ASCII-range using a character object with its Unicode name, simply replacing the space word-separators with underscores (_). This is a little unusual for the Lisp world, since symbol names normally use the - (hyphen/dash) character as the word-separator; but as I said in Section 1.1.3, the Common Lisp Style Guide, that is a naming convention, which in this case isn't followed.

Some of these characters you've seen before, but lets go through a few so you get used to typing them out:


These names are not case-sensitive: you could type #\Greek_Small_Letter_Lamda, #\GREEK_SMALL_LETTER_LAMDA, or even #\gReEK_sMaLl_LeTtER_lAmDA, and the Lisp reader will see it the same---for style and legibility of your code, however, you should stick with the lower-case names. You can use this syntax to enter any Unicode character into the SBCL REPL.

What You Should See

* #\subscript_three
* #\greek_small_letter_lamda
* #\greek_capital_letter_sigma
* #\cuneiform_sign_an_plus_naga_opposing_an_plus_naga

When you enter a character object at the REPL, it returns itself. When you want the character's glyph, i.e., what it will look like in a string, you need to put the character into a string. This will be covered in a later exercise.

You've probably noticed that the Greek letter lambda's name is "misspelled" in the example above. It's not a mistake, this is the actual character name in the Unicode standard, because the name of the letter is no longer spelled with the letter beta following the mu in modern Greek.

This is a good opportunity to remind you to type in exactly, character for character, what I have in the example code into the REPL. Did you get an error when typing the above example? Check what you typed, and make sure you typed exactly what you're supposed to.

results matching ""

    No results matching ""