I have an alist in the following form:
((|* bank accounts| (|account 1| |account 2|)) (|* airline miles| (|account 1| |account 2|)) ..... .....) I don't how to use assoc to access the symbols, since they're framed on both sides with "|".
Quoted symbols are treated like any other symbol, but the string case of the symbol is preserved:
(assoc '|foo bar| '((|baz| . 1) (|foo bar| . 2))) => (|foo bar| . 2)
Here are some more examples (with standard reader case settings):
(intern "foo bar") => |foo bar|
(intern "Foo") => |Foo|
(intern "FOO") => FOO
A longer answer can be found on cliki. Please also refer to 2.3.4 Symbols as Tokens in the Common Lisp Hyperspec.
The same way they are printed:
> (defparameter *alist* '((|* bank accounts| |account 1| |account 2|) (|* airline miles| |account 1| |account 2|))) *ALIST* > (cdr (assoc '|* bank accounts| *alist*)) (|account 1| |account 2|) > (cdr (assoc '|* airline miles| *alist*)) (|account 1| |account 2|) The vertical-bars are just multiple escape characters allowing the use of characters which the standard reader wouldn't read as a symbol. For example, whitespace would result in separate symbols in standard reader syntax:
> (read-from-string "foo bar") FOO ; 4 Numbers won't yield a symbol:
> (read-from-string "123 456") 123 ; 4 > (type-of *) (INTEGER 0 16777215) Without escaping, and the default readtable-case, the read symbols would be in upper case:
> 'foo FOO But:
> (intern "1234") |1234| ; NIL > (type-of *) SYMBOL > '|foo bar baz| |foo bar baz| > (symbol-name *) "foo bar baz"