| Author |
Message |
jayasree
Guest
|
Posted:
Wed Oct 12, 2005 12:10 am Post subject:
compare two lists |
|
|
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 |
|
|
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 |
|
 |
CarlB
Joined: 27 Sep 2005
Posts: 52
|
Posted:
Wed Oct 12, 2005 11:55 pm Post subject:
re:compare two lists |
|
|
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 |
|
 |
mguzik@nospamlawson-fishe
Guest
|
Posted:
Fri Oct 14, 2005 4:10 pm Post subject:
Re: compare two lists |
|
|
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 |
|
 |
|
|
|
|