Jump to content

Recommended Posts

Posted

I have 2, equal length, lists with items like: ((x y z) name)

 

Example List 1:

(((496502.36 5733207.41 0.0) S4_WTG-H01) ((495332.36 5734422.41 0.0) S4_WTG-H02) ((493742.36 5734362.41 0.0) S4_WTG-H03) ((493427.36 5735207.41 0.0) S4_WTG-H04) ((492132.276311227 5734917.0 0.0) S4_WTG-H05))

 

Example List 2:

(((496502.36 5733207.41 0.0) S4_OSS-H01_CASE2_AP-ORG) ((495332.36 5734422.41 0.0) S4_H01-H02_CASE2_AP-ORG) ((493742.36 5734362.41 0.0) S4_H02-H03_CASE2_AP-ORG) ((493427.36 5735207.41 0.0) S4_H03-H04_CASE2_AP-ORG) ((492300.0 5734917.0 0.0) S4_H04-H05_CASE2_AP-ORG))

 

I want to compare the 2 lists based on the (x y z) coordinate.

how can i get the list1 items ((x y z) name), which xyz coordinates are not matching any of the xyz coordinates of list2?

 

Notes:

 

  • Both lists might be ordered randomly
  • In the example lists shown, 1 coordinate is not matching for testing purposes

 

I found something like:

 

(vl-remove-if '(lambda (x) (member (x) list2)) list1)

with above code, list1 should end up with only the not matching ((x y z) name) items.

Now x is ((x y z) name) but I need to compare the (car x) = (x y z).

 

But I read somewhere that it is not possible to check with 'member' if coordinates are (not) equal?

Anyone an idea how to approach this?

Posted

Try the following:

(defun foo ( lst1 lst2 )
   (vl-remove-if
       (function
           (lambda ( itm1 )
               (vl-some
                   (function
                       (lambda ( itm2 )
                           (equal (car itm1) (car itm2) 1e-
                       )
                   )
                   lst2
               )
           )
       )
       lst1
   )
)

_$ (foo list1 list2)
(((492132.0 5.73492e+006 0.0) S4_WTG-H05))

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