Jump to content

if (item of member of list) is equal 0.0 (remove member)


reza

Recommended Posts

HI everyone

I have this list: ((0.0 70.8187) (0.0 -119.977) (61.875 44.4858)) or ((88.21 0.0) (19.80 0.0) (61.875 44.4858))

I want remove all member if x=0 or y=0 then remove members of list==> ((61.875 44.4858))

Link to comment
Share on other sites

Given that we're working with reals, I would suggest the use of the equal function with an appropriate tolerance - I would reserve zerop for when testing integer values.

 

Hence:

(vl-remove-if '(lambda ( x ) (or (equal (car x) 0.0 1e-8) (equal (cadr x) 0.0 1e-8))) lst)

 

Or, for any coordinate:

(vl-remove-if '(lambda ( x ) (vl-some '(lambda ( y ) (equal y 0.0 1e-8)) x)) lst)

 

  • Like 2
  • Thanks 1
Link to comment
Share on other sites

3 hours ago, reza said:

Dear Jonathan:

🙏🙏🙏
thanks a lot again.

No worries. Glad to help.

However, I do agree with what Lee mentioned. His function should be slightly more bulletproof than mine.

Link to comment
Share on other sites

  • 1 month later...
On 10/21/2022 at 11:37 PM, marko_ribar said:

With that I want to remove, you pretty much don't need computer or state of mind...

Deleted

Edited by troggarf
Link to comment
Share on other sites

Dear troggarf:
I'm sorry that I paid attention to your reply so late.
I have used the advice of experts like you and dear Marko many times in different forums.
I think it's my fault that I bore Marco with very simple questions.

🙏🙏🙏

Link to comment
Share on other sites

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