[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: EXPLODE/IMPLODE equivalents
Hi,
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.
nathan@bristol.st.com writes:
> 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)
#\A
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")
FOO ;
3
> (intern "foo")
|foo| ;
NIL
> (intern (string-upcase "foo"))
FOO ;
:INTERNAL
Bye,
Jo"rg Ho"hle.
Joerg.Hoehle@gmd.de hoehle@zeus.gmd.de