Detect String
Detect String
In CLISP, how to detect whether an object is a string or not?
-
- Posts: 94
- Joined: Mon Jul 21, 2008 7:26 am
- Location: München, Germany
- Contact:
Re: Detect String
You can use STRINGP.
In general, TYPECASE and CTYPECASE are often more useful.
Code: Select all
[1]> (stringp "abc")
T
[2]> (stringp 100)
NIL
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.")))