Detect String

Discussion of Common Lisp
Post Reply
anirban
Posts: 2
Joined: Sun Jan 15, 2012 2:12 pm

Detect String

Post by anirban » Sun Jan 15, 2012 2:14 pm

In CLISP, how to detect whether an object is a string or not?

Kompottkin
Posts: 94
Joined: Mon Jul 21, 2008 7:26 am
Location: München, Germany
Contact:

Re: Detect String

Post by Kompottkin » Mon Jan 16, 2012 2:40 am

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.")))

anirban
Posts: 2
Joined: Sun Jan 15, 2012 2:12 pm

Re: Detect String

Post by anirban » Mon Jan 16, 2012 6:39 am

Thanks everyone!

Post Reply