Detect String

Discussion of Common Lisp

Detect String

Postby anirban » Sun Jan 15, 2012 2:14 pm

In CLISP, how to detect whether an object is a string or not?
anirban
 
Posts: 2
Joined: Sun Jan 15, 2012 2:12 pm

Re: Detect String

Postby 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.")))
User avatar
Kompottkin
 
Posts: 94
Joined: Mon Jul 21, 2008 7:26 am
Location: München, Germany

Re: Detect String

Postby anirban » Mon Jan 16, 2012 6:39 am

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


Return to Common Lisp

Who is online

Users browsing this forum: No registered users and 2 guests