Page 1 of 1

Detect String

Posted: Sun Jan 15, 2012 2:14 pm
by anirban
In CLISP, how to detect whether an object is a string or not?

Re: Detect String

Posted: Mon Jan 16, 2012 2:40 am
by Kompottkin
You can use STRINGP.

Code: Select all

[1]> (stringp "abc")
T
[2]> (stringp 100)
NIL
In general, TYPECASE and CTYPECASE are often more useful.

Code: Select all

(typecase x
  (string
   (format t "~&X is a string."))
  (number
   (format t "~&X is a number."))
  (t
   (format t "~&X is... something.")))

Re: Detect String

Posted: Mon Jan 16, 2012 6:39 am
by anirban
Thanks everyone!