drafter007 Posted July 19, 2012 Posted July 19, 2012 How can i check if one element in a list is a string? Quote
MSasu Posted July 19, 2012 Posted July 19, 2012 The basic answer is to check the TYPE function: (equal (type "abc") 'STR) But may be useful to give more details of your issue; you want to validate the element from a certain position, or if the list contains (at least) one string, or other scenario? Quote
Lee Mac Posted July 19, 2012 Posted July 19, 2012 Using vl-some: (vl-some '(lambda ( x ) (= 'str (type x))) <your list>) Another, recursive: (defun _stringinlist ( l ) (and l (or (= 'str (type (car l))) (_stringinlist (cdr l)))) ) Quote
drafter007 Posted July 19, 2012 Author Posted July 19, 2012 I just wanted to eliminate strings from a list...thanks! Quote
MSasu Posted July 19, 2012 Posted July 19, 2012 Then: (vl-remove-if '(lambda(x) (equal (type x) 'STR)) listToProcess) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.