inverting case



Dear James,
Dear *,

I want to make the TeXmacs interface compatible with the current maxima 
and forthcoming 5.9.2. I need to change one function: in 
texmacs-maxima-5.9.1.lisp it is

(defun tex-stripdollar (sym)
  (or (symbolp sym) (return-from tex-stripdollar sym))
  (let* ((name (symbol-name sym))
      (name1 (if (memq (elt name 0) '(#\$ #\&)) (subseq name 1) name))
      (name2 (if (eql (elt name1 0) #\%) (concatenate 'string "\\" name1) name1))
      (l (length name2)))
    (if (eql l 1) name2 (concatenate 'string "\\mathrm{" name2 "}"))))

(I don't really understand what is return-from, but the rest of it is 
quite simple). Now I need name to be (symbol-name sym) with inverted case 
of all characters. I asked on this list how to do it, and got no answer. 
So I decided to write this thing myself. This is the result:

(defun tex-stripdollar (sym)
  (or (symbolp sym) (return-from tex-stripdollar sym))
  (let*
      ((name
        (map 'string
          #'(lambda (c)
            (cond
              (upper-case-p c) (char-downcase c)
              (lower-case-p c) (char-upcase c)
              c))
          (string sym)))
      (name1 (if (memq (elt name 0) '(#\$ #\&)) (subseq name 1) name))
      (name2 (if (eql (elt name1 0) #\%) (concatenate 'string "\\" name1) name1))
      (l (length name2)))
    (if (eql l 1) name2 (concatenate 'string "\\mathrm{" name2 "}"))))

Seems straightforward. But I get the error message:

Error in COND [or a callee]: The variable UPPER-CASE-P is unbound.

(this is in gcl-2.6.6). Why is it unbound? I cannot understand.

Any help very much appreciated,

Andrey