[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EXPLODE/IMPLODE equivalents
Juan Jordana Jord writes:
> IMPLODE and EXPLODE ??
This is a Lisp FAQ and not specific to CLISP:
: Subject: [2-3] What is the equivalent of EXPLODE and IMPLODE in Common Lisp?
Please refer to it.
> CLISP has strings as first class objects, therefore IMPLODE and EXPLODE
> are not required. To get at the characters in a symbol use princ-to-string
Better use the more specific functions:
> (char (symbol-name 'bar) 1)
SCHAR could probably be used instead of CHAR because it's likely (?)
that symbol names are of type simple-string.
> and then elt. To create a symbol from a string use read-from-string.
READ-FROM-STRING is generally not good, because the result depends on
whether the readtable preserves the case of characters. The default
readtable will uppercase names. Furthermore, it will not work with
unusual characters. Use INTERN instead. However old code using
IMPLODE and EXPLODE will probably only know about alphanumeric
characters that are all uppercase.
> (read-from-string "foo")
> (intern "foo")
> (intern (string-upcase "foo"))