Problem With Members of a List

Problem With Members of a List

mgorecki
Collaborator Collaborator
766 Views
2 Replies
Message 1 of 3

Problem With Members of a List

mgorecki
Collaborator
Collaborator

I have a list of points "extPolyEndpointList":

((4950.0 8910.0) (4950.0 6930.0) (2970.0 4950.0) (2970.0 1980.0) (990.0 6930.0) (990.0 7485.36) (5445.0 7425.0) (5423.79 5423.79) (5940.0 -4950.0) (5940.0 -8910.0) (1980.0 -6930.0) (1980.0 -8910.0) )

I have a point "extPolyConnStart ":

(990.0 7485.36)

I tried using the command: (member extPolyConnStart extPolyEndpointList)

but it keeps returning nil.  I can clearly see that it's the 6th item in the list.

Am I not doing the command right?

I get the point using this command:

(setq extPolyConnStart (cdr (assoc 10 extPolyConnEnt)))      --->(10 990.0 7485.36)

I have tried so many variations:

(member 'extPolyConnStart extPolyEndpointList)

(member '(extPolyConnStart) extPolyEndpointList)

(member (list extPolyConnStart) extPolyEndpointList)

I hope someone can let me know how I need to set this up so that it does recognize the point as part of the list.

 

Thanks

0 Likes
Accepted solutions (1)
767 Views
2 Replies
Replies (2)
Message 2 of 3

_gile
Consultant
Consultant
Accepted solution

Hi

 

Dealing with real numbers requires to use come tolerance in equality comparison (that's related to binary encode real numbers with double-precision floating-point format).

 

You can use some a routine like this one:

(defun gc:memberFuzz (expr lst fuzz)
  (while (and lst (not (equal (car lst) expr fuzz)))
    (setq lst (cdr lst))
  )
  lst
)

Using example:

(gc:memberfuzz extPolyConnStart extPolyEndpointList 0.000001)

 



Gilles Chanteau
Programmation AutoCAD LISP/.NET
GileCAD
GitHub

Message 3 of 3

mgorecki
Collaborator
Collaborator

Hello _gile,

Thank you for that.  It worked perfectly.

 

Best regards,

Mark

0 Likes