Jump to content

Recommended Posts

Posted

How can i check if one element in a list is a string?

Posted

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?

Posted

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

Posted

I just wanted to eliminate strings from a list...thanks!

Posted

Then:

(vl-remove-if '(lambda(x) (equal (type x) 'STR)) listToProcess)

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...