compare two lists
CADForums.net Forum Index CADForums.net
Discussion of AutoCAD and other CAD software.
 
 FAQFAQ   MemberlistMemberlist     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Google
 
Web cadforums.net
compare two lists

 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization
Author Message
jayasree
Guest





Posted: Wed Oct 12, 2005 12:10 am    Post subject: compare two lists Reply with quote

i got two lists which has the insertion point and the end point

ex ins_pt (-3.5432 4.5678)
end_pt (-3.5432 4.5678)

When i use (equal ins_pt end_pt) it returns nil.

Is there any other way to compare both lists and return T.

Thanks,
Jayasree

Back to top
Adesu



Joined: 20 Jul 2005
Posts: 31

Posted: Wed Oct 12, 2005 12:34 am    Post subject: Re: compare two lists Reply with quote

Hi jayasree,test it
Code:

(setq ex_ins_pt '(-3.5432 4.5678))
(setq end_pt '(-3.5432 4.5678))
(if
  (equal ex_ins_pt end_pt 0.0001)
  (princ "\nThat right,it's same value")
  (princ "\nThat wrong,it's not same value")
  )


jayasree wrote:
i got two lists which has the insertion point and the end point

ex ins_pt (-3.5432 4.5678)
end_pt (-3.5432 4.5678)

When i use (equal ins_pt end_pt) it returns nil.

Is there any other way to compare both lists and return T.

Thanks,
Jayasree
Back to top
View user's profile Send private message
CarlB



Joined: 27 Sep 2005
Posts: 52

Posted: Wed Oct 12, 2005 11:55 pm    Post subject: re:compare two lists Reply with quote

If your points are calculated, you may think they're equal but they may differ in the 16th decimal point. You may want to use a fuzz factor, as in (equal PtA PtB 0.0000001)

Back to top
View user's profile Send private message
mguzik@nospamlawson-fishe
Guest





Posted: Fri Oct 14, 2005 4:10 pm    Post subject: Re: compare two lists Reply with quote

If my memory is correct equal is used for comparing list and eq for
variables.

So using the two points above in the following will yield true:

(setq ins_pt '(-3.5432 4.5678)
end_pt '(-3.5432 4.5678))
(if (equal ins_pt end_pt)
(princ "\nThey are equal ")
(princ "\nThey are not equal")
)
(princ)

Also try with two lists that are not exactly the same with the optional
fuzz input variable of equal:

(setq ins_pt '(-3.5432 4.567)
end_pt '(-3.5432 4.566))
(if (equal ins_pt end_pt 0.005)
(princ "\nThey are equal ")
(princ "\nThey are not equal")
)

Hope this helps comparing lists
Back to top
 
Post new topic   Reply to topic    CADForums.net Forum Index -> Customization All times are GMT
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum




Windows Server DSP VoIP Electronics New Topics
Powered by phpBB