PDA

View Full Version : please help - function returns Nil



muthu123
23rd Feb 2010, 09:56 am
i have copied the following result from console window. If you look at it the pt1 is part of the purlin_ins_pt_list_left. But when i use the function member it returns nil. Please suggest the correct way.


_$ pt1
(8955.33 6895.53 0.0)
_$ purlin_ins_pt_list_left
((1492.56 6149.26 0.0) (2985.11 6298.51 0.0) (4477.67 6447.77 0.0) (5970.22 6597.02 0.0) (7462.78 6746.28 0.0) (8955.33 6895.53 0.0) (10447.9 7044.79 0.0) (11940.4 7194.04 0.0) (13433.0 7343.3 0.0) (14925.6 7492.56 0.0))
_$ (member pt1 purlin_ins_pt_list_left)
nil
_$

jammie
23rd Feb 2010, 01:46 pm
It could be the precision of either pt1 or purlin_ins_pt_list_left


The concept is correct though



(setq pt1 '(8955.33 6895.53 0.0))

(setq purlin_ins_pt_list_left '((1492.56 6149.26 0.0) (2985.11 6298.51 0.0) (4477.67 6447.77 0.0) (5970.22 6597.02 0.0) (7462.78 6746.28 0.0) (8955.33 6895.53 0.0) (10447.9 7044.79 0.0) (11940.4 7194.04 0.0) (13433.0 7343.3 0.0) (14925.6 7492.56 0.0)))

(member pt1 purlin_ins_pt_list_left)

David Bethel
23rd Feb 2010, 02:10 pm
( member ) looks for exact matches so Jammie is probably correct with the precession query

I'd try something like this:


(setq found nil)
(foreach p purlin_ins_pt_list_left
(and (equal p pt1 1e-4)
(setq found T)))
found


-David